Flows¶
We introduced the pipe operator ->
in the previous section and we
saw how we can pipe results of a function into another one. Using the
pipe operator, you can chain as many function calls as you want:
The above adds 2
and 3
first, then multiplies them by 4
,
then prints out the result. To format your code you can put indents
before the ->
operator, for example:
Map¶
Using pipes, you can also map a function to a value, for example, to print an array we can write:
and to print each item in the array, we can map the console.log
function to the array:
As you see, in Clio we use -> *
to map functions to values. This
operator can be used in a flow:
Methods¶
We can call methods in flows, using the pipe operator:
This will call toUpperCase
method of "hello"
, and then pipe the
result to console.log
!