February 2019
Beginner to intermediate
180 pages
4h 4m
English
A last-resort option is to use actual JavaScript within Reason:
let array = [|"first", "second", "third"|];let map = [%raw {| function(f, array) { return array.map(f) }|}];map(e => e ++ "-mapped", array)
BuckleScript lets us drop into raw JavaScript as a way to stay productive while we're learning. Of course, when doing this, we give up the safety that Reason provides us with. So, once you are ready, convert any raw JavaScript code back into more idiomatic Reason.
When it comes to using raw JavaScript, use % for expressions and %% for statements. Remember, the {| |} is Reason's multiline string syntax:
let array = [%raw "['first', 'second', 'third']"];[%%raw {| array = array.map(e => e + "-mapped");|}];
Using the raw ...
Read now
Unlock full access