るりまサーチ (Ruby 2.3.0)

最速Rubyリファレンスマニュアル検索!
9件ヒット [1-9件を表示] (0.141秒)
トップページ > バージョン:2.3.0[x] > 種類:インスタンスメソッド[x] > クエリ:l[x] > クラス:BasicObject[x]

別のキーワード

  1. matrix l
  2. kernel $-l
  3. _builtin $-l
  4. lupdecomposition l

ライブラリ

検索結果

BasicObject#equal?(other) -> bool (18307.0)

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

...ものであるかどうかを判定します。
一般にはこのメソッドを決して再定義すべきでありません。
ただし、 BasicObject の位置づけ上、どうしても再定義が必要な用途もあるでしょう。
再定義する際には自分が何をしているの...

BasicObject#instance_eval {|obj| ... } -> object (18307.0)

オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。

...ソッドが定義されます。これはメソッド定義のネストと同じです。
d:spec/def#nest_method を参照してください。

BasicObject
を継承して作ったクラス内で instance_eval する場合はトップレベルの定数や Kernel モジュールに定義されて...
...imeError)
//}

//emlist[例][ruby]{
class Bar < BasicObject
def call1
instance_eval("::ENV.class")
end
def call2
instance_eval("ENV.class")
end
end

bar = Bar.new
bar.call1 # => Object
bar.call2 # raise NameError
//}

@see Module#module_eval, Kernel.#eval, BasicObject#instance_exec...

BasicObject#instance_eval(expr, filename = "(eval)", lineno = 1) -> object (18307.0)

オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。

...ソッドが定義されます。これはメソッド定義のネストと同じです。
d:spec/def#nest_method を参照してください。

BasicObject
を継承して作ったクラス内で instance_eval する場合はトップレベルの定数や Kernel モジュールに定義されて...
...imeError)
//}

//emlist[例][ruby]{
class Bar < BasicObject
def call1
instance_eval("::ENV.class")
end
def call2
instance_eval("ENV.class")
end
end

bar = Bar.new
bar.call1 # => Object
bar.call2 # raise NameError
//}

@see Module#module_eval, Kernel.#eval, BasicObject#instance_exec...

BasicObject#singleton_method_added(name) -> object (18307.0)

特異メソッドが追加された時にインタプリタから呼び出されます。

...emlist[例][ruby]{
class Foo
def singleton_method_added(name)
puts "singleton method \"#{name}\" was added"
end
end

obj = Foo.new
def obj.foo
end

#=> singleton method "foo" was added
//}

@see Module#method_added,BasicObject#singleton_method_removed,BasicObject#singleton_method_undefined...

BasicObject#singleton_method_removed(name) -> object (18307.0)

特異メソッドが Module#remove_method に より削除された時にインタプリタから呼び出されます。

...method_removed(name)
puts "singleton method \"#{name}\" was removed"
end
end

obj = Foo.new
def obj.foo
end

class << obj
remove_method :foo
end

#=> singleton method "foo" was removed
//}

@see Module#method_removed,BasicObject#singleton_method_added,BasicObject#singleton_method_undefined...

絞り込み条件を変える

BasicObject#singleton_method_undefined(name) -> object (18307.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#! -> bool (307.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 (307.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...

BasicObject#==(other) -> bool (307.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...