Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@baweaver
Created September 8, 2020 06:03
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 baweaver/444d027c2a859baf3f5123854e3fbac7 to your computer and use it in GitHub Desktop.
Save baweaver/444d027c2a859baf3f5123854e3fbac7 to your computer and use it in GitHub Desktop.
# 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