るりまサーチ

最速Rubyリファレンスマニュアル検索!
24件ヒット [1-24件を表示] (0.107秒)

別のキーワード

  1. _builtin to_i
  2. fiddle to_i
  3. matrix elements_to_i
  4. kernel $-i
  5. bigdecimal to_i

ライブラリ

検索結果

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

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

...//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#==, Obje...

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

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

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

ただし、 BasicObject#!= 自身や BasicObject#! を再定義...
...ェクト
@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 != 1
puts 'hoge' if recorder != "str...