Skip to content

Instantly share code, notes, and snippets.

@rohitpaulk
Last active September 8, 2019 19:33
Show Gist options
  • Select an option

  • Save rohitpaulk/d063f699bcff526170d0e901d253f52a to your computer and use it in GitHub Desktop.

Select an option

Save rohitpaulk/d063f699bcff526170d0e901d253f52a to your computer and use it in GitHub Desktop.
NamedStruct
class NamedStruct < Struct
# Allows initialization via keyword arguments. By default, Ruby
# only allows positional arguments.
def initialize(**kwargs)
super(*members.map{|k| kwargs[k] })
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment