Ruby 1.9.3 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Structクラス > ==

instance method Struct#==

self == other -> bool

自身と other のクラスが同じであり、各メンバが == メソッドで比較して等しい場合に true を返します。そうでない場合に false を返します。

[PARAM] other:
自身と比較したいオブジェクトを指定します。
Dog = Struct.new(:name, :age)
dog1 = Dog.new("fred", 5)
dog2 = Dog.new("fred", 5)

p dog1 == dog2                #=> true
p dog1.eql?(dog2)             #=> true
p dog1.equal?(dog2)           #=> false

[SEE_ALSO] Struct#eql?

class Struct