Created
April 16, 2024 12:06
-
-
Save Mazuh/bdef80ca9dad4dfed91d29a7a7e76582 to your computer and use it in GitHub Desktop.
Elixir example of pattern matching for equal values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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