Ruby Language Attribute lookup


Example

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"