168件ヒット
[101-168件を表示]
(0.044秒)
ライブラリ
- ビルトイン (168)
キーワード
- ! (12)
- != (12)
- == (12)
-
_ _ id _ _ (12) -
_ _ send _ _ (24) - equal? (12)
-
instance
_ eval (24) -
instance
_ exec (12) -
method
_ missing (12) -
singleton
_ method _ added (12) -
singleton
_ method _ removed (12) -
singleton
_ method _ undefined (12)
検索結果
先頭5件
-
BasicObject
# singleton _ method _ undefined(name) -> object (3103.0) -
特異メソッドが Module#undef_method または undef により未定義にされた時にインタプリタから呼び出されます。
...foo
end
def obj.bar
end
class << obj
undef_method :foo
end
obj.instance_eval {undef bar}
#=> singleton method "foo" was undefined
# singleton method "bar" was undefined
//}
@see Module#method_undefined,BasicObject#singleton_method_added,BasicObject#singleton_method_removed , d:spec/def#undef... -
BasicObject
# _ _ id _ _ -> Integer (3056.0) -
各オブジェクトに対して一意な整数を返します。あるオブジェクトに対し てどのような整数が割り当てられるかは不定です。
...は不定です。
Object#object_id と同じですが、#object_id は BasicObject に
はない事に注意してください。
//emlist[例][ruby]{
# frozen_string_literal: false
obj = Object.new
obj.object_id == obj.__id__ # => true
Object.new.__id__ == Object.new.__id__ # => f......alse
(21 * 2).__id__ == (21 * 2).__id__ # => true
"hello".__id__ == "hello".__id__ # => false
"hi".freeze.__id__ == "hi".freeze.__id__ # => true
//}
@see Object#object_id, 42840... -
BasicObject
# ==(other) -> bool (3026.0) -
オブジェクトが other と等しければ真を、さもなくば偽を返します。
...デフォルトでは Object#equal? と同じオブジェクトの同一性になっています。
@param other 比較対象となるオブジェクト
@return other が 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 (3020.0) -
オブジェクトが other と同一であれば真を、さもなくば偽を返します。
...ものであるかどうかを判定します。
一般にはこのメソッドを決して再定義すべきでありません。
ただし、 BasicObject の位置づけ上、どうしても再定義が必要な用途もあるでしょう。
再定義する際には自分が何をしているの......さもなくば偽
//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
# ! -> bool (3002.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... -
BasicObject
# !=(other) -> bool (3002.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...