Skip to content

Instantly share code, notes, and snippets.

@jrunning
Created January 17, 2013 14:14
Show Gist options
  • Select an option

  • Save jrunning/4556183 to your computer and use it in GitHub Desktop.

Select an option

Save jrunning/4556183 to your computer and use it in GitHub Desktop.
class InheritsFromStruct < Struct.new(:foo)
end
insty = InheritsFromStruct.new 100
puts insty[:foo]
# => 100
class InheritsFromStruct
def double_foo
self[:foo] * 2
end
end
puts insty.double_foo
# => 200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment