るりまサーチ

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

別のキーワード

  1. object yield_self
  2. _builtin yield_self
  3. _builtin self
  4. tracepoint self
  5. codeobject document_self=

ライブラリ

キーワード

検索結果

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

オブジェクトが other と等しければ真を、さもなくば偽を返します。

...ther が self と同値であれば真、さもなくば偽

//emlist[例][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?,
Object#eql?...

BasicObject#equal?(other) -> bool (19.0)

オブジェクトが other と同一であれば真を、さもなくば偽を返します。

...し、 BasicObject の位置づけ上、どうしても再定義が必要な用途もあるでしょう。
再定義する際には自分が何をしているのかよく理解してから実行してください。

@param other 比較対象となるオブジェクト
@return other が self 自身...
...さもなくば偽

//emlist[例][ruby]{
original = "a"
copied = original.dup
substituted = original

original == copied #=> true
original == substituted #=> true
original.equal? copied #=> false
original.equal? substituted #=> true
//}

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

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

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

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

ただし、 BasicObject#!= 自身や BasicObject#! を再定...
...義するものと想定されています。

@param other 比較対象となるオブジェクト
@see BasicObject#==, BasicObject#!

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

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