るりまサーチ

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

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. fiddle type_size_t
  4. fiddle type_ssize_t
  5. t61string new

ライブラリ

検索結果

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

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

...ュールのコンテキストで評価します。

モジュールのコンテキストで評価するとは、実行中そのモジュールが self になるということです。
つまり、そのモジュールの定義式の中にあるかのように実行されます。

ローカル変...
...す。


//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 (3133.0)

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

...ュールのコンテキストで評価します。

モジュールのコンテキストで評価するとは、実行中そのモジュールが self になるということです。
つまり、そのモジュールの定義式の中にあるかのように実行されます。

ローカル変...
...す。


//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...