るりまサーチ

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

別のキーワード

  1. objectspace each_object
  2. _builtin each_object
  3. object send
  4. object enum_for
  5. object to_enum

ライブラリ

キーワード

  • ! (12)
  • != (12)

検索結果

BasicObject#! -> bool (3107.0)

オブジェクトを真偽値として評価し、その論理否定を返します。

...order < BasicObject
def initialize
@count = 0
end
attr
_reader :count

def !
@count += 1
super
end
end

recorder = NegationRecorder.new
!recorder
!!!!!!!recorder
puts 'hoge' if !recorder

puts recorder.count #=> 3
//}

//emlist[例][ruby]{
class AnotherFalse < BasicObject
def...
...!
true
end
end
another_false = AnotherFalse.new

# another_falseは*真*
puts "another false is a truth" if another_false
#=> "another false is a truth"
//}...

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

オブジェクトが 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
end
end
recorder = None...
...qualityRecorder.new

recorder != 1
puts 'hoge' if recorder != "str"

p recorder.count #=> 2
//}...