Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Struct#==

struct == other → true or false

Equality—Returns true if other has the same struct subclass and has equal member values (according to Object#==).

Example
Customer = Struct.new(:name, :address, :zip)
joe   = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
joejr = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
jane  = Customer.new("Jane Doe", "456 Elm, Anytown NC", 12345)
joe == joejr   #=> true
joe == jane    #=> false
See also .new #[] .json_create #[]= also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1