NOTE: Running Elixir v0.12.5 or later the % symbol for sigils was deprecated so use ~ instead. So %r should be entered as ~r instead: Regex.split(~r/ /, stripped, trim: true)

Hello again, and welcome to ElixirSips Episode 16 - Pipe Operator.

In today's episode, I'm going to cover the pipe operator. Let's get started.

The Pipe Operator: |> is used to quickly and easily create a pipeline of functions. It's an extremely common thing you run into in programming.

In Unix, a pipeline might look something like this:

ps ax|grep vim|awk '{ print $1 }'

This would list the processes out, grep the resulting lines for the string vim, and print out their PID. There are substantially better ways to accomplish this, but it serves as a pretty comprehensible example.

The reason Unix has a means of piping the output of one program into the input of another is that it's an exceedingly useful way of composing small operations into large, useful expressions.

It turns out...