Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/syntax-cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ Both JavaScript and Reason support currying, but Reason currying is **built-in a
| `for (let i = 10; i >= 0; i--) {...}` | `for (i in 10 downto 0) {...}` |
| `while (true) {...}` | Same |

## forEach / map

| JavaScript | Reason |
|------------------------------------------|-------------------------------------------|
|`[1,2,3].forEach(i => { console.log(i) })`|`Array.iter(i => { Js.log(i) }, [|1,2,3|])`|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason version can be Array.iter(Js.log, [|1, 2, 3|])

|`[1,2,3].map(i => { return i + 1 })` |`Array.map(i => i + 1, [|1,2,3|])` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason version can be Array.map(succ, [|1, 2, 3|]). Admittedly i => i + 1 is just as valid but if we want to show the idiomatic way of doing things in OCaml/Reason we might as well teach the built-in functions...


## JSX

| JavaScript | Reason |
Expand Down