るりまサーチ

最速Rubyリファレンスマニュアル検索!
24件ヒット [1-24件を表示] (0.147秒)
トップページ > クエリ:t[x] > クエリ:Ruby[x] > 種類:インスタンスメソッド[x] > クエリ:end[x] > クラス:Module[x] > クエリ:>[x] > クエリ:class_exec[x]

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. document implicit_end=

ライブラリ

検索結果

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

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

...//emlist[例][ruby]{
class Thing
end

c = 1

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


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

}

t
= Thing.new
p t.hello() #=> "Hello there!"
p t.foo() #=> 1
//}...
...@see Module#module_eval, Module#class_eval...

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

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

...//emlist[例][ruby]{
class Thing
end

c = 1

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


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

}

t
= Thing.new
p t.hello() #=> "Hello there!"
p t.foo() #=> 1
//}...
...@see Module#module_eval, Module#class_eval...