What is the pipe operator in Elixir?
Answer
The pipe operator (|>) passes the result of the left expression as the first argument to the right function. It enables readable, left-to-right function composition without deeply nested calls. Without pipe: String.downcase(String.trim(String.replace(input, " ", "_"))). With pipe: input |> String.replace(" ", "_") |> String.trim() |> String.downcase(). The result of each step is the first argument of the next. It is similar to Unix pipes: cat file | grep pattern | sort | uniq. Real example: users |> Enum.filter(&(&1.active)) |> Enum.sort_by(&(&1.name)) |> Enum.take(10). The pipe operator encourages data-first function design — functions should take the primary data as the first argument. It is one of the most beloved Elixir features for producing readable data transformation pipelines.