るりまサーチ

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

別のキーワード

  1. module attr
  2. module public
  3. module protected
  4. module private
  5. module new

ライブラリ

クラス

キーワード

検索結果

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

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

...に渡す引数を指定します。


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

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

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

end
}

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

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

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

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

...に渡す引数を指定します。


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

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

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

end
}

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

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

BasicObject#instance_exec(*args) {|*vars| ... } -> object (6106.0)

与えられたブロックをレシーバのコンテキストで実行します。

...タに渡す値です。

//emlist[例][ruby]{
c
lass KlassWithSecret
def initialize
@secret = 99
end
end
k = KlassWithSecret.new
# 以下で x には 5 が渡される
k.instance_exec(5) {|x| @secret + x } #=> 104
//}

@see Module#class_exec, Module#module_exec, BasicObject#instance_eval...

ruby 1.9 feature (24.0)

ruby 1.9 feature ruby version 1.9.0 は開発版です。 以下にあげる機能は将来削除されたり互換性のない仕様変更がなされるかもしれません。 1.9.1 以降は安定版です。 バグ修正がメインになります。

...* [new]: 追加されたクラス/メソッドなど
* [compat]: 変更されたクラス/メソッドなど(互換性のある変更) (only backward-compatibility) (影響の範囲が小さいと思われる変更もこちら)
* [change]: 変更されたクラス/メソッドなど(互換...
...: Struct#inspect

=== 2006-09-14

: digest.rb
: Digest::Base.file

=== 2006-09-13

: Hash#compare_by_identity
: Hash#compare_by_identity?
: Hash#identical
: Hash#identical?

=== 2006-09-12

: Hash#compare_by_identity
: Hash#compare_by_identity?

=== 2006-09-11

: Hash#identical
: Hash#identical?

=...
...solete]
: chop [obsolete]
: chop! [obsolete]
: chomp [obsolete]
: chomp! [obsolete]
: split [obsolete]
: scan [obsolete]

削除

=== 2005-10-21
: funcall [new]

fcall から改名

: Module#instance_exec [new]
: Module#module_exec [new]...