How to pass an anonymous function to the pipe in Elixir

elixir

Solution

It will look bit weird but must work:

def boundary do
  :crypto.rand_bytes(8)
  |> Base.encode16
  |> (&("--------FormDataBoundary" <> &1)).()
end

Problem

I'd like to write the code like this: ``` def boundary do :crypto.rand_bytes(8) |> Base.encode16 |> &("--------FormDataBoundary" <> &1) end ``` But it doesn't work.

Original source

Related problems