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:

  1. Start with "hello world"
  2. Reverse it with String.reverse
  3. Uppercase it with String.upcase
  4. Print the result with IO.puts
JS Transpiler loading...
Loading...
Click "Run" to execute your code.