Created
July 20, 2022 13:44
-
-
Save oieioi/99317db346e14ad01443d44cac325c54 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
class Hash | |
def to_struct | |
klass = Struct.new(*keys.map(&:to_sym).uniq, keyword_init: true) | |
klass.new(self) | |
end | |
end | |
pp({ :keys => 'arienai', 'keys' => 'unko'}.to_struct) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment