るりまサーチ

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

別のキーワード

  1. argf.class each
  2. argf.class each_line
  3. argf.class lines
  4. class new
  5. argf.class to_a

ライブラリ

クラス

検索結果

Module#class_exec(*args) {|*vars| ... } -> object (18119.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 (3019.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...