Created
September 8, 2020 06:03
-
-
Save baweaver/444d027c2a859baf3f5123854e3fbac7 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
# Ideal syntax for pattern matched methods: | |
def handle_response(body) | |
in 200, response | |
# Ok response | |
in 500, error | |
# Handle failure | |
else | |
# No idea? | |
end | |
# Hack variant: | |
def handle_response(body) | |
_in 200, response do | |
# Ok response | |
end | |
_in 500, error do | |
# Handle failure | |
end | |
_else do | |
# No idea? | |
end | |
end | |
# With live AST can be transposed to: | |
def handle_response(body) | |
case response | |
in 200, response | |
# Ok response | |
in 500, error | |
# Handle failure | |
else | |
# No idea? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment