るりまサーチ

最速Rubyリファレンスマニュアル検索!
11件ヒット [1-11件を表示] (0.030秒)
トップページ > クエリ:kernel[x] > クエリ:$2[x] > クエリ:caller[x] > 種類:文書[x]

別のキーワード

  1. kernel $kcode
  2. kernel $srcdir
  3. kernel $safe
  4. kernel $cflags
  5. kernel $archdir

検索結果

クラス/メソッドの定義 (31.0)

クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined

...タを定義する方法の一つです。イテレータを定義する代表的な方法は
yield を呼び出すことです。
他に Proc.new/Kernel.#proc を使う方法などもあります。
ブロックが与えられなかった場合のブロック引数の値はnilです。

//emlist[...
...ト(メソッド定義式やinstance_eval)でのみ呼び出せ
ます。

//emlist[例: protected の可視性][ruby]{
class Foo
def foo
p caller.last
end
protected :foo
end

obj = Foo.new

# そのままでは呼べない
obj.foo rescue nil # => -:11 - protected method `foo' called...
...# => [2, 2]

$bar = 3
alias $foo $bar
$bar = 4
p [$foo, $bar] # => [4, 4]
//}

ただし、正規表現の部分文字列に対応する変数 $1,$2, ... には別名を付けることができません。
また、インタプリタに対して重要な意味のあるグローバル変数
(d:spe...