るりまサーチ

最速Rubyリファレンスマニュアル検索!
24件ヒット [1-24件を表示] (0.092秒)
トップページ > クエリ:end[x] > クエリ:initialize[x] > クラス:BasicObject[x] > クエリ:==[x]

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. document implicit_end=

ライブラリ

検索結果

BasicObject#==(other) -> bool (18131.0)

オブジェクトが other と等しければ真を、そうでない場合は偽を返します。

...[ruby]{
class Person < BasicObject
def initialize(name, age)
@name = name
@age = age
end

end


tanaka1 = Person.new("tanaka", 24)
tanaka2 = Person.new("tanaka", 24)

tanaka1 == tanaka1 #=> true
tanaka1 == tanaka2 #=> false
//}

@see BasicObject#equal?, Object#==, Object#equal?,...

BasicObject#!=(other) -> bool (31.0)

オブジェクトが other と等しくないことを判定します。

...トでは self == other を評価した後に結果を論理否定して返します。
このため、サブクラスで BasicObject#== を再定義しても != とは自動的に整合性が
とれるようになっています。

ただし、 BasicObject#!= 自身や BasicObject#! を再定義...
...her 比較対象となるオブジェクト
@see BasicObject#==, BasicObject#!

//emlist[例][ruby]{
class NonequalityRecorder < BasicObject
def initialize
@count = 0
end

attr_reader :count

def !=(other)
@count += 1
super
end

end

recorder = NonequalityRecorder.new

recorder !=...