Sha256: e5c8e3cf641ed8d82be5e52487d42f7df829ead4c8f20f2e112de81c82fd8190
Contents?: true
Size: 719 Bytes
Versions: 40
Compression:
Stored size: 719 Bytes
Contents
# Struct `[]` ------ Access a value in the Struct by key, like a Hash. ```ruby person = Struct.new(:name, :age) person.new('bob', 60) person['name'] #=> 'bob' ``` `[]=` ------ Store a value in the Struct by key, like a Hash. ```ruby person = Struct.new(:name, :age) person.new('bob', 60) person['name'] = 'tim' person['name'] #=> 'tim' ``` `attributes` ------ Returns the key values of the assigned struct. ```ruby person = Struct.new(:name, :age) person.new('bob', 60) person.attributes #=> { name: 'bob', age: 60 } ``` `replace` ------ Replaces values provided within the hash. ```ruby person = Struct.new(:name, :age) person.new('bob', 60) person.replace(name: 'tom', age: 28) preson.name #=> 'tom' ```
Version data entries
40 entries across 40 versions & 1 rubygems