るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

検索結果

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

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

...end
c = 1

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

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

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

@see Module#module_eval, Modul...

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

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

...end
c = 1

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

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

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

@see Module#module_eval, Modul...