属性查找
属性可以作为键访问字符串和符号。数字索引也有效。
Person = Struct.new :name
alice = Person.new 'Alice'
alice['name'] # => "Alice"
alice[:name] # => "Alice"
alice[0] # => "Alice"
属性可以作为键访问字符串和符号。数字索引也有效。
Person = Struct.new :name
alice = Person.new 'Alice'
alice['name'] # => "Alice"
alice[:name] # => "Alice"
alice[0] # => "Alice"