モジュール
- Kernel (154)
キーワード
-
$ 1 (11) -
$ 10 (11) -
$ 11 (11) -
$ 3 (11) -
$ 4 (11) -
$ 5 (11) -
$ 6 (11) -
$ 7 (11) -
$ 8 (11) -
$ 9 (11) -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - StringScanner (11)
- caller (33)
- クラス/メソッドの定義 (11)
- 変数と定数 (11)
検索結果
先頭5件
-
Kernel
$ $ 2 -> String | nil (15240.0) -
最後に成功したパターンマッチで n 番目の括弧にマッチした値が格納されます。 該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)
...最後に成功したパターンマッチで n 番目の括弧にマッチした値が格納されます。
該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)
番号 n はいくらでも大きな正整数を利用できます。
Regexp.last_matc......れらの変数はローカルスコープかつスレッドローカル、読み取り専用です。
//emlist[例][ruby]{
str = '<p><a href="http://example.com">example.com</a></p>'
if %r[<a href="(.*?)">(.*?)</a>] =~ str
print $1
print $2
end
#=> "http://example.com"
#=> "example.com"
//}... -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (1242.0) -
1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))
...りました。
* nil: 警告を出力しない (-W0 新しい警告レベル)
* false: 重要な警告のみ出力 (-W1 デフォルト)
* true: すべての警告を出力する (-W2 or -W or -v or -w or --verbose)
追加された -W オプションは $VERBOSE = nil の指定(-W0)を......よくわかりません(^^;
class << Object
p [self.id, self]
class << self
p [self.id, self]
end
end
=> ruby 1.6.7 (2002-03-01) [i586-linux]
[537771634, Class]
[537742484, Class]
=> ruby 1.7.3 (2002-09......(以前は環境依存。大抵の場合"GMT")
== 文法の変更
: parser [compat]
数字で始まるグローバル変数は特殊変数 $1, $2, ... 以外に許されなくな
りました。
: [parser], [change]
`*' による配列展開が、多重代入の右辺で行われた場... -
クラス/メソッドの定義 (666.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...fined
===[a:class] クラス定義
//emlist[例][ruby]{
class Foo < Super
def test
# ...
end
# ...
end
//}
文法:
class 識別子 [`<' superclass ]
式..
end
文法:
class 識別子 [`<' superclass ]
式..
[rescue [erro......返さない場合は nil を返します。
===[a:singleton_class] 特異クラス定義
//emlist[例][ruby]{
obj = Object.new # obj = nil でも可
class << obj
def test
# ...
end
# ...
end
//}
文法:
class `<<' expr
式..
end
文法:
clas......変数 $1,$2, ... には別名を付けることができません。
また、インタプリタに対して重要な意味のあるグローバル変数
(d:spec/variables#builtin_variable を参照)を再定義すると動作に
支障を来す場合があります。
alias 式は nil を返し... -
変数と定数 (246.0)
-
変数と定数 * local * instance * class * class_var_scope * global * pseudo * const * prio
... nil
# 1
# nil <- これが nil であることに注意
# 1
//}
宣言は、たとえ実行されなくても宣言とみなされます。
//emlist[][ruby]{
v = 1 if false # 代入は行われないが宣言は有効
p defined?(v) # => "local-variable"
p v # => nil......ます。初期化されていない
インスタンス変数を参照した時の値はnilです。
===[a:class] クラス変数
//emlist[例][ruby]{
class Foo
@@foo = 1
def bar
puts @@foo
end
end
//}
@@で始まる変数はクラス変数です。クラス変数はクラス定義
の......変数の一部は、通常の変数としては使用できない特殊な名前を持っています。
例えば、 $' や $& あるいは $1, $2, $3 がそうです。
このように 「'$' + 特殊文字一文字」、または「'$' + 10進数字」という名前を持つ変数を特殊変... -
Kernel
. # caller(range) -> [String] | nil (175.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。
引数で指定した値が範囲外の場合は nil を返します。
@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得するス......caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end
def bar
foo
end
bar
#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}
以下の関数は、caller の要素から [ファイル....../ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(caller.first)
end
def bar
foo
p parse_caller(caller.first)
end
bar
p parse_caller(caller.first)
#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}
以下は、$DEBUG が真... -
Kernel
. # caller(start = 1) -> [String] | nil (175.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。
引数で指定した値が範囲外の場合は nil を返します。
@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得するス......caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end
def bar
foo
end
bar
#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}
以下の関数は、caller の要素から [ファイル....../ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(caller.first)
end
def bar
foo
p parse_caller(caller.first)
end
bar
p parse_caller(caller.first)
#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}
以下は、$DEBUG が真... -
Kernel
. # caller(start , length) -> [String] | nil (175.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。
引数で指定した値が範囲外の場合は nil を返します。
@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得するス......caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end
def bar
foo
end
bar
#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}
以下の関数は、caller の要素から [ファイル....../ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(caller.first)
end
def bar
foo
p parse_caller(caller.first)
end
bar
p parse_caller(caller.first)
#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}
以下は、$DEBUG が真... -
Kernel
$ $ 1 -> String | nil (140.0) -
最後に成功したパターンマッチで n 番目の括弧にマッチした値が格納されます。 該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)
...最後に成功したパターンマッチで n 番目の括弧にマッチした値が格納されます。
該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)
番号 n はいくらでも大きな正整数を利用できます。
Regexp.last_matc......れらの変数はローカルスコープかつスレッドローカル、読み取り専用です。
//emlist[例][ruby]{
str = '<p><a href="http://example.com">example.com</a></p>'
if %r[<a href="(.*?)">(.*?)</a>] =~ str
print $1
print $2
end
#=> "http://example.com"
#=> "example.com"
//}... -
Kernel
$ $ 10 -> String | nil (140.0) -
最後に成功したパターンマッチで n 番目の括弧にマッチした値が格納されます。 該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)
...最後に成功したパターンマッチで n 番目の括弧にマッチした値が格納されます。
該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)
番号 n はいくらでも大きな正整数を利用できます。
Regexp.last_matc......れらの変数はローカルスコープかつスレッドローカル、読み取り専用です。
//emlist[例][ruby]{
str = '<p><a href="http://example.com">example.com</a></p>'
if %r[<a href="(.*?)">(.*?)</a>] =~ str
print $1
print $2
end
#=> "http://example.com"
#=> "example.com"
//}... -
Kernel
$ $ 11 -> String | nil (140.0) -
最後に成功したパターンマッチで n 番目の括弧にマッチした値が格納されます。 該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)
...最後に成功したパターンマッチで n 番目の括弧にマッチした値が格納されます。
該当する括弧がなければ nil が入っています。(覚え方: \数字 のようなもの)
番号 n はいくらでも大きな正整数を利用できます。
Regexp.last_matc......れらの変数はローカルスコープかつスレッドローカル、読み取り専用です。
//emlist[例][ruby]{
str = '<p><a href="http://example.com">example.com</a></p>'
if %r[<a href="(.*?)">(.*?)</a>] =~ str
print $1
print $2
end
#=> "http://example.com"
#=> "example.com"
//}...