id | keywords | name | summary | category | ||||
---|---|---|---|---|---|---|---|---|
pipe |
|
-> |
This is the `pipe` operator. |
operators |
The ->
operator provides an convenient syntax for passing a value into a function. Typically it's used to pass a value into a function as its first argument.
<CodeTab labels={["ReScript", "JS Output"]}>
let dieRoll = size => {
Js.Math.random_int(1, size)
}
let dieRollMessage = (value, name) => {
"Hi " ++ name ++ ", you rolled a " ++ Js.Int.toString(value)
}
let message = dieRoll(6)->dieRollMessage("Marshall")
function dieRoll(size) {
return Js_math.random_int(1, size);
}
function dieRollMessage(value, name) {
return "Hi " + name + ", you rolled a " + value.toString();
}
var message = dieRollMessage(Js_math.random_int(1, 6), "Marshall");
Which produces a message such as Hello Marshall, you rolled a 3
.