- ReasonML Quick Start Guide
- Raphael Rafatpanah Bruno Joseph D'mello
- 70字
- 2021-07-02 12:34:15
Creating our own types
We can also create our types:
type person = (string, int);
/* or */
type name = string;
type age = int;
type person = (name, age);
Here's how we create a person of the person type:
let person = ("Zoe", 3);
We can also annotate any expression with its type:
let name = ("Zoe" : string);
let person = ((name, 3) : person);