unit
์ ํ์ ๋จ์ผ ์์ ๋ ์ฝ๋๋ฅผ ์์ฑํ ๋ ์์ฑ๋ ํด๋์ค ์์ฑ์๋ ์ ํจํ์ง ์์ผ๋ฉฐ ๋ฐํ์์ ReferenceError๋ฅผ ์์ฑํฉ๋๋ค.
์ฐํ REPL ์ํ...
type Test = {
Abc: unit
}
printfn "%A" <| { Abc = () }
์์ฐ:
import { setType } from "fable-core/Symbol";
import _Symbol from "fable-core/Symbol";
import { compareRecords, equalsRecords, Unit } from "fable-core/Util";
import { printf, toConsole } from "fable-core/String";
export class Test {
constructor() {
this.Abc = abc;
}
[_Symbol.reflection]() {
return {
type: "Test.Test",
interfaces: ["FSharpRecord", "System.IEquatable", "System.IComparable"],
properties: {
Abc: Unit
}
};
}
Equals(other) {
return equalsRecords(this, other);
}
CompareTo(other) {
return compareRecords(this, other) | 0;
}
}
setType("Test.Test", Test);
toConsole(printf("%A"))(new Test());
์์ฑ์์์ ํ๋๋ฅผ ์ด๊ธฐํํ๋ ๋ฐ ์ฌ์ฉํ๋ abc
์ธ์๊ฐ ๋๋ฝ๋์์ต๋๋ค.
type Test = {
Abc: unit
Xyz: int
}
printfn "%A" <| { Abc = (); Xyz = 123 }
์์ฐ:
import { setType } from "fable-core/Symbol";
import _Symbol from "fable-core/Symbol";
import { compareRecords, equalsRecords, Unit } from "fable-core/Util";
import { printf, toConsole } from "fable-core/String";
export class Test {
constructor(abc, xyz) {
this.Abc = abc;
this.Xyz = xyz | 0;
}
[_Symbol.reflection]() {
return {
type: "Test.Test",
interfaces: ["FSharpRecord", "System.IEquatable", "System.IComparable"],
properties: {
Abc: Unit,
Xyz: "number"
}
};
}
Equals(other) {
return equalsRecords(this, other);
}
CompareTo(other) {
return compareRecords(this, other) | 0;
}
}
setType("Test.Test", Test);
toConsole(printf("%A"))(new Test(null, 123));
๋ฐ๋ผ์ ๋ ์ฝ๋์ ๋ค๋ฅธ ํ๋๊ฐ ์ถ๊ฐ๋๋ฉด ์์ฑ์๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ํ์ฑ๋ฉ๋๋ค.
REPL์ ํตํด์๋ ๊ด์ฐฐ๋ ์ต์ ๋ชจ๋ ๊ฒ(Fable 1).
@xdaDaveShaw๋ฅผ ํ์ธํด์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค! Fable 2 @SirUppyPancakes์์ ์๋ํ๋ ๊ฒฝ์ฐ ์ด ๋ฌธ์ ๋ฅผ ๋ซ์๋ ๋ ๊น์?
์, ํ์คํ!
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
Fable2์์ ๊ด์ฐฎ์ ๋ณด์ธ๋ค
์ฌ๊ธฐ Repl์ด ์๋ ํฉ๋๋ค.
์ฝ์:
{Abc = null}