Using Elixir pipe example



To demonstrate how pipe operator is used in Elixir, we try out with the following codes.

defmodule Test do
   def exact(a) do
     a
   end
 
   def toInt(a) do
     Integer.parse(a)
   end

end

This basically takes 200, pass it to Test.exact (which returns anything that it get) and pass it on to Test.toInt which convert it into an integer. 


"200" |> Test.exact |> Test.toInt



Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm