Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

elixir guards

defmodule Guard do
  def kind_of(x) when is_binary(x) do
    "#{x} is a binary"
  end

  def kind_of(x) when is_atom(x) do
    "#{x} is an atom"
  end

  def is_ten(x) when x > 10, do: "Greater than ten"

  def is_ten(x) when x < 10, do: "Less than ten"

  def is_ten(x), do: "Yes"
end
Source by kapeli.com #
 
PREVIOUS NEXT
Tagged: #elixir #guards
ADD COMMENT
Topic
Name
6+1 =