Created
June 8, 2021 00:17
-
-
Save BrooklinJazz/e4f71bc5f3cafd1a3b76778b5956ccbe to your computer and use it in GitHub Desktop.
Elixir example using when in a function
This file contains hidden or 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 Greeting do | |
| def say_hello(name) when name === "Brooklin" do | |
| "Oh it's just you again" | |
| end | |
| def say_hello(name) do | |
| "Hello #{name}" | |
| end | |
| end | |
| Greeting.say_hello("Brooklin") # Oh it's just you again |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment