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

ionic2 cordova build android - Unable resolve gradle 2.2.3

OpenCover code coverage for .Net Core

Using Custom DLL with IronPython / Scripts