Skip to content

Instantly share code, notes, and snippets.

@baweaver
Created January 10, 2021 05:20
Show Gist options
  • Save baweaver/4e5e67278f2a00d4c34ff4c0d649053c to your computer and use it in GitHub Desktop.
Save baweaver/4e5e67278f2a00d4c34ff4c0d649053c to your computer and use it in GitHub Desktop.
class Either
def self.deconstruct_keys(*)
{ Right: Right, Left: Left }
end
class Right < Struct.new(:value); end
class Left < Struct.new(:value); end
end
Either => { Right:, Left: }
# Current:
#
# SyntaxError ((irb):62: key must be valid as local variables)
# Either in { Right:, Left: }
# ^~~~~~
# Proposed:
[Right, Left]
# => [Either::Right, Either::Left]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment