Elixir Function Guards

[Solved] Elixir Function Guards | Elixir - Code Explorer | yomemimo.com
Question : elixir function guards

Answered by : nguyen-quang-huy

defmodule Greeter do def hello(names) when is_list(names) do names = Enum.join(names, ", ") hello(names) end def hello(name) when is_binary(name) do phrase() <> name end defp phrase, do: "Hello, "
end
iex> Greeter.hello ["Sean", "Steve"]
# "Hello, Sean, Steve"

Source : | Last Update : Tue, 07 Jun 22

Answers related to elixir function guards

Code Explorer Popular Question For Elixir