Lesson 10 of 16
Pipe Operator
|>
The pipe operator |> passes the result of one expression as the first argument to the next. It makes data transformation pipelines readable:
Without pipe:
String.upcase(String.reverse("hello world"))
With pipe:
"hello world"
|> String.reverse()
|> String.upcase()
Both produce "DLROW OLLEH".
Your Turn
Use the pipe operator to:
- Start with
"hello world" - Reverse it with
String.reverse - Uppercase it with
String.upcase - Print the result with
IO.puts
JS Transpiler loading...
Loading...
Click "Run" to execute your code.