はじめに Elixir の Pipe は処理の記述を簡潔にすることができる便利なマクロであり、比較的利用する場面は多いことと思います。 この記事では、そんな Pipe に関する、開発が楽しくなるかもしれないちょっとしたTipsを紹介します。 1. IO.inspect を挟んで値を出力 Pipe の途中に IO.inspect を挟み込む ことで、処理している途中の値をコンソールに表示させることができます。 IO.inspect は与えられた値をそのまま戻り値として返すので Pipe の前後の動作に影響を与えることもなく、デバッグ時に有用な方法と言えるでしょう。 defmodule Hoge do def do_something do 10 |> plus(7) |> IO.inspect() |> minus(2) end def plus(x, y), do: x + y def m