るりまサーチ

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

別のキーワード

  1. object true
  2. _builtin true
  3. rb_true
  4. true object

ライブラリ

キーワード

検索結果

BasicObject#__id__ -> Integer (19.0)

各オブジェクトに対して一意な整数を返します。あるオブジェクトに対し てどのような整数が割り当てられるかは不定です。

...ct_id は BasicObject
はない事に注意してください。

//emlist[例][ruby]{
# frozen_string_literal: false
obj = Object.new
obj.object_id == obj.__id__ # => true
Object.new.__id__ == Object.new.__id__ # => false
(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#equal?(other) -> bool (19.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 (7.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 (7.0)

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

...list[例][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#equ...