Skip to content

Instantly share code, notes, and snippets.

@Mazuh
Created April 16, 2024 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mazuh/bdef80ca9dad4dfed91d29a7a7e76582 to your computer and use it in GitHub Desktop.
Save Mazuh/bdef80ca9dad4dfed91d29a7a7e76582 to your computer and use it in GitHub Desktop.
Elixir example of pattern matching for equal values
defmodule Comp do
def equals?(same, same), do: true
def equals?(one, another), do: false
end
IO.inspect Comp.equals?(4, 2)
# false
IO.inspect Comp.equals?(42, 42)
# true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment