Attribute lookup

suggest change

Attributes can be accessed strings and symbols as keys. Numerical indexes also work.

Person = Struct.new :name
alice = Person.new 'Alice'

alice['name']  # => "Alice"
alice[:name]   # => "Alice"
alice[0]       # => "Alice"

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents