33件ヒット
[1-33件を表示]
(0.274秒)
ライブラリ
- ビルトイン (33)
クラス
- BasicObject (33)
検索結果
先頭3件
-
BasicObject
# instance _ exec(*args) {|*vars| . . . } -> object (26107.0) -
与えられたブロックをレシーバのコンテキストで実行します。
...タに渡す値です。
//emlist[例][ruby]{
class KlassWithSecret
def initialize
@secret = 99
end
end
k = KlassWithSecret.new
# 以下で x には 5 が渡される
k.instance_exec(5) {|x| @secret + x } #=> 104
//}
@see Module#class_exec, Module#module_exec, BasicObject#instance_eval... -
BasicObject
# instance _ eval {|obj| . . . } -> object (8006.0) -
オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。
...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 (8006.0) -
オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。
...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...