るりまサーチ

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

別のキーワード

  1. object false
  2. _builtin false
  3. rb_false
  4. false
  5. false object

ライブラリ

検索結果

BasicObject#! -> bool (55.0)

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

... nil または false であれば真を、さもなくば偽を返します。
主に論理式の評価に伴って副作用を引き起こすことを目的に
再定義するものと想定されています。

このメソッドを再定義しても Ruby の制御式において nil false...
...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"
//}...