概要
Elixirの対話モードでパイプ演算子の動作を確認してみました。以下のページを参考にしました。
対話モードで実行
以下のコマンドを実行しました。
$ iex
Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit]
Interactive Elixir (1.12.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> "Elixir rocks" |> String.split()
["Elixir", "rocks"]
iex(2)> "Elixir rocks" |> String.upcase() |> String.split()
["ELIXIR", "ROCKS"]
iex(3)> "elixir" |> String.ends_with?("ixir")
true
iex(4)> "elixir" |> String.ends_with? "ixir"
warning: parentheses are required when piping into a function call. For example:
foo 1 |> bar 2 |> baz 3
is ambiguous and should be written as
foo(1) |> bar(2) |> baz(3)
Ambiguous pipe found at:
iex:4
true
iex(5)>
まとめ
何かの役に立てばと。