Flowdock
[]=(p1, p2) public

Attribute Assignment—Sets the value of the given struct member or the member at the given index. Raises NameError if the name does not exist and IndexError if the index is out of range.

Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)

joe["name"] = "Luke"
joe[:zip]   = "90210"

joe.name   #=> "Luke"
joe.zip    #=> "90210"
Show source
Register or log in to add new notes.