I am learning Elixir and I wonder why I can’t use anon function in a pipe but must use the then macro
For example this works
“Hello” |> String.reverse |> String.upcase |> then(&(“Weird text #{&1}”))
But of course this does not
“Hello” |> String.reverse |> String.upcase |> &(“Weird text #{&1}”)
Even in a module I need to access the function with the module prefix
defmodule Test do
def fx(x) do
"Weird Text #{x}"
end
def try(str) do
str
|> String.upcase
|> String.reverse
|> Test.fx #<--- this line
end
end