やりたいこと パターンマッチをバキバキに仕上げてくれるのが、whenから始まるguard構文。標準で様々な演算子と関数が使えるようになっている。やや量が多いので、しっかりと使いこなせるようにするため汎用性の高そうなguardを一通り書いてみた。 演算子 演算子は以下のものが利用可能。詳細はこちら参照 defmodule Demo.GuardTest do use Demo.ConnCase def this_is(x) when is_nil(x), do: "This is nil" def this_is(x) when is_atom(x), do: "This is Atom" def this_is(x) when is_binary(x), do: "This is Binary" def this_is(x) when is_bitstring(x), do: "This i