Created
June 24, 2020 12:12
-
-
Save sinsoku/0c11f108502d96239d01acaba7c3ddb6 to your computer and use it in GitHub Desktop.
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
enum = Enum.new(:a, :b, :c) | |
status = :b | |
# pattern 1 | |
enum.case status do | |
_when(:a) do | |
p :a | |
end | |
_when :b do | |
p :b | |
end | |
_when :c do | |
p :c | |
end | |
end | |
# pattern 2 | |
enum.case(status) | |
.when(:a) do | |
p :a | |
end.when(:b) do | |
p :b | |
end.when(:c) do | |
p :c | |
end.end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment