Skip to content

Commit 169298b

Browse files
committed
improve pipefirst
1 parent 8955279 commit 169298b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

docs/pipe-first.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,25 @@ Basically, `parseData(person)` is transformed into `person->parseData`, and `get
2828
**Pipe first operator always applies the value to the _first_ argument of the function, even if that function takes more than one argument**.
2929

3030
```reason
31-
a(one, two, three)
31+
fn(one, two, three)
3232
```
3333

3434
is the same as
3535

3636
```reason
37-
one->a(two, three)
37+
one->fn(two, three)
3838
```
3939

40-
This works with labeled arguments too.
40+
This can be combined with labeled arguments. For example if a function `foo` is defined as:
41+
42+
```reason
43+
let foo = (~two, ~three, data) => // { ... }
44+
```
45+
46+
Note that the last argument isn't labelled, and it can be called with pipe-first like this:
47+
48+
```reason
49+
data->foo(~two, ~three)
50+
```
4151

4252
This section is documented under Melange's documentation as well: [Pipe first](https://melange.re/v2.0.0/communicate-with-javascript/#pipe-first).

0 commit comments

Comments
 (0)