Elixir Defguard

[Solved] Elixir Defguard | Elixir - Code Explorer | yomemimo.com
Question : elixir defguard

Answered by : nasty-nightingale-6kbfxg59j1af

defmodule SomeModule do defguard greater_than_five_less_than_nine_number(x) when x > 5 and x < 9 @doc """ iex> SomeModule.do_something(6) "It's greater than 5 and less than 9!" iex> SomeModule.do_something(3) "Not in the range :(" """ def do_something(num) when greater_than_five_less_than_nine_number(num) do "It's greater than 5 and less than 9!" end def do_something(_num) do "Not in the range :(" end
end

Source : | Last Update : Sun, 22 May 22

Answers related to elixir defguard

Code Explorer Popular Question For Elixir