End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
OpenStruct#set_ostruct_member_value!
set_ostruct_member_value!(name, value)
lib/ostruct.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/ostruct.rb, line 278
def []=(name, value)
name = name.to_sym
new_ostruct_member!(name)
@table[name] = value
end
Alias of #[]=
Sets the value of an attribute.
Example
require "ostruct" person = OpenStruct.new("name" => "John Smith", "age" => 70) person[:age] = 42 # equivalent to person.age = 42 person.age # => 42