るりまサーチ

最速Rubyリファレンスマニュアル検索!
22件ヒット [1-22件を表示] (0.084秒)

別のキーワード

  1. _builtin define_method
  2. rake define_task
  3. main define_method
  4. mutex_m define_aliases
  5. module define_method

クラス

検索結果

Module#class_exec(*args) {|*vars| ... } -> object (18128.0)

与えられたブロックを指定された args を引数としてモジュールのコンテキストで評価します。

...

@param args ブロックに渡す引数を指定します。


//emlist[例][ruby]{
class Thing
end
c = 1

Thing.class_exec{
def hello()
"Hello there!"
end

define
_method(:foo) do # ローカル変数がブロックの外側を参照している
c
end
}

t = Thing.new
p
t.he...
...llo() #=> "Hello there!"
p
t.foo() #=> 1
//}

@see Module#module_eval, Module#class_eval...

Module#module_exec(*args) {|*vars| ... } -> object (3028.0)

与えられたブロックを指定された args を引数としてモジュールのコンテキストで評価します。

...

@param args ブロックに渡す引数を指定します。


//emlist[例][ruby]{
class Thing
end
c = 1

Thing.class_exec{
def hello()
"Hello there!"
end

define
_method(:foo) do # ローカル変数がブロックの外側を参照している
c
end
}

t = Thing.new
p
t.he...
...llo() #=> "Hello there!"
p
t.foo() #=> 1
//}

@see Module#module_eval, Module#class_eval...