22件ヒット
[1-22件を表示]
(0.032秒)
検索結果
-
Kernel
$ $ & -> String | nil (18119.0) -
現在のスコープで最後に成功した正規表現のパターンマッチでマッチした文字列です。 最後のマッチが失敗していた場合には nil となります。
...プかつスレッドローカル、読み取り専用です。
Ruby起動時の初期値は nil です。
//emlist[例][ruby]{
str = '<p><a href="http://example.com">example.com</a></p>'
if %r[<a href="(.*?)">(.*?)</a>] =~ str
p $&
end
#=> "<a href=\"http://example.com\">example.com</a>"
//}... -
クラス/メソッドの定義 (30.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...# (Net のインスタンスがない。Net を include できるなどのため)
module Net
class HTTP
end
class FTP
end
end
obj = Net::HTTP.new
# あるいは
include Net
obj = HTTP.new
# 以下のような使い方は組み込みのクラスにも見られる
# 利用者は File::Con......ついてはd:spec/control#begin参照。
メソッド定義式は、メソッド名を Symbol にしたオブジェクトを返します。
@see https://magazine.rubyist.net/articles/0041/0041-200Special-kwarg.html
====[a:operator] 演算子式の定義
spec/operatorにおいて、「再定義......f._val + other._val
end
end
//}
=== 定義に関する操作
====[a:alias] alias
//emlist[例][ruby]{
alias foo bar
alias :foo :bar
alias $MATCH $&
//}
文法:
alias 新メソッド名 旧メソッド名
alias 新グローバル変数名 旧グローバル変数名
メソ...