るりまサーチ

最速Rubyリファレンスマニュアル検索!
168件ヒット [101-168件を表示] (0.059秒)
トップページ > クエリ:Ruby[x] > クエリ:ruby[x] > 種類:インスタンスメソッド[x] > クエリ:@[x] > クエリ:j[x] > クラス:BasicObject[x]

別のキーワード

  1. fiddle ruby_free
  2. rbconfig ruby
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

検索結果

<< < 1 2 >>

BasicObject#singleton_method_undefined(name) -> object (3126.0)

特異メソッドが Module#undef_method または undef により未定義にされた時にインタプリタから呼び出されます。

...ます。

@
param name 未定義にされたメソッド名が Symbol で渡されます。

//emlist[例][ruby]{
class Foo
def singleton_method_undefined(name)
puts "singleton method \"#{name}\" was undefined"
end
end

obj = Foo.new
def obj.foo
end
def obj.bar
end

class << obj
undef_meth...
...od :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#! -> bool (3056.0)

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

...を再定義しても Ruby の制御式において nil や false 以外が偽として
扱われることはありません。

@
return オブジェクトが偽であれば真、さもなくば偽

//emlist[例][ruby]{
class NegationRecorder < BasicObject
def initialize
@
count = 0
end
att...
...r_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

# anoth...

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

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

...bject#equal? と同じオブジェクトの同一性になっています。

@
param other 比較対象となるオブジェクト
@
return other が self と同値であれば真、さもなくば偽

//emlist[例][ruby]{
class Person < BasicObject
def initialize(name, age)
@
name = name
@
a...
...ge = 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#!=(other) -> bool (3038.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
rec...

BasicObject#__id__ -> Integer (3032.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#equal?(other) -> bool (3032.0)

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

...
ただし、 BasicObject の位置づけ上、どうしても再定義が必要な用途もあるでしょう。
再定義する際には自分が何をしているのかよく理解してから実行してください。

@
param other 比較対象となるオブジェクト
@
return other が se...
...さもなくば偽

//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?...
<< < 1 2 >>