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

gemini cli getting file not defined error

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20

vllm : Failed to infer device type