Tuples are:
let ageAndName: (int, string) = (24, "Lil' ReScript")
// a tuple type alias
type coord3d = (float, float, float)
let my3dCoordinates: coord3d = (20.0, 30.5, 100.0)
type person = {
age: int,
name: string
}
let me = {
age: 5,
name: "Big ReScript"
}
type person = {
"age": int
};
let me = {
"age": "hello!" // age is a string. No error.
}
Most data structures in most languages are about "this and that". A variant allows us to express "this or that"
type myResponse =
| Yes
| No
| PrettyMuch
let areYouCrushingIt = Yes
/* JS Output */
let areYouCrushingIt = /* Yes */0;
Constructor Arguments
type account =
| None
| Instagram(string)
| Facebook(string, int)
let myAccount = Facebook("josh", 26)
let friendAccount = Instagram("Jenny")
Variants Must Have Constructors