February 2019
Beginner to intermediate
180 pages
4h 4m
English
Ask yourself whether the following is a statement or an expression:
let foo = "bar";
In JavaScript, it's a statement, but in Reason, it's an expression. Another example of an expression is 4 + 3, which can also be represented as 4 + (2 + 1).
Many things in Reason are expressions, including control structures such as if-else, switch, for and while:
let message = if (true) { "Hello"} else { "Goodbye"};
We also have ternaries in Reason. Here is another way to express the preceding code:
let message = true ? "Hello" : "Goodbye";
Even anonymous block scopes are expressions that evaluate to the last line's expression:
let message = { let part1 = "Hello"; let part2 = "World"; {j|$part1 $part2|j};};/* message evaluates to "Hello ...Read now
Unlock full access