66件ヒット
[1-66件を表示]
(0.120秒)
検索結果
先頭5件
-
MatchData
# begin(n) -> Integer | nil (27337.0) -
n 番目の部分文字列先頭のオフセットを返します。
...nilを返します。
@param n 部分文字列を指定する数値。
@raise IndexError 範囲外の n を指定した場合に発生します。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.begin(0) # => 0
p $~.begin(1) # => 0
p $~.begin(2) # => 3
p $~.begin(3) # => nil......p $~.begin(4) # => `begin': index 4 out of matches (IndexError)
//}
@see MatchData#end... -
MatchData
# offset(n) -> [Integer , Integer] | [nil , nil] (3214.0) -
n 番目の部分文字列のオフセットの配列 [start, end] を返 します。
...list[例][ruby]{
[ self.begin(n), self.end(n) ]
//}
と同じです。n番目の部分文字列がマッチしていなければ
[nil, nil] を返します。
@param n 部分文字列を指定する数値
@raise IndexError 範囲外の n を指定した場合に発生します。
@see MatchData#......begin, MatchData#end......begin, MatchData#end, MatchData#offset... -
MatchData
# offset(name) -> [Integer , Integer] | [nil , nil] (3214.0) -
name という名前付きグループに対応する部分文字列のオフセットの配列 [start, end] を返 します。
...nd] を返
します。
//emlist[例][ruby]{
[ self.begin(name), self.end(name) ]
//}
と同じです。nameの名前付きグループにマッチした部分文字列がなければ
[nil, nil] を返します。
@param name 名前(シンボルか文字列)
@raise IndexError 正規表現中で......す。
//emlist[例][ruby]{
/(?<year>\d{4})年(?<month>\d{1,2})月(?:(?<day>\d{1,2})日)?/ =~ "2021年1月"
p $~.offset('year') # => [0, 4]
p $~.offset(:year) # => [0, 4]
p $~.offset('month') # => [5, 6]
p $~.offset(:month) # => [5, 6]
p $~.offset('day') # => [nil, nil]
p $~.offset(......'century') # => `offset': undefined group name reference: century (IndexError)
//}
@see MatchData#begin, MatchData#end......'century') # => `offset': undefined group name reference: century (IndexError)
//}
@see MatchData#begin, MatchData#end, MatchData#offset... -
MatchData
# end(n) -> Integer | nil (3106.0) -
n 番目の部分文字列終端のオフセットを返します。
...ば nil を返します。
@param n 部分文字列を指定する数値。
@raise IndexError 範囲外の n を指定した場合に発生します。
//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.end(0) # => 6
p $~.end(1) # => 3
p $~.end(2) # => 6
p $~.end(3) # => nil
p $~.......end(4) # => `end': index 4 out of matches (IndexError)
//}
@see MatchData#begin... -
制御構造 (386.0)
-
制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END
...制御構造
条件分岐:
* if
* unless
* case
繰り返し:
* while
* until
* for
* break
* next
* redo
* retry
例外処理:
* raise
* begin
その他:
* return
* BEGIN
* END
Rubyでは(Cなどとは異なり)制御構造は式であ......す.
=== 条件分岐
====[a:if] if
//emlist[例][ruby]{
if age >= 12 then
print "adult fee\n"
else
print "child fee\n"
end
gender = if foo.gender == "male" then "male" else "female" end
//}
文法:
if 式 [then]
式 ...
[elsif 式 [then]
式 ... ]......hile io_not_ready?
//}
文法:
式 while 式
右辺の式を評価した値が真の間、左辺を繰り返し実行します。
左辺の式が begin 節である場合にはそれを最初に一回評価してから繰り返します。
//emlist[例][ruby]{
send_request(data)
begin... -
Ruby用語集 (70.0)
-
Ruby用語集 A B C D E F G I J M N O R S Y
...Ruby用語集
A B C D E F G I J M N O R S Y
a ka sa ta na ha ma ya ra wa
=== 記号・数字
: %記法
: % notation
「%」記号で始まる多種多様なリテラル記法の総称。
参照:d:spec/literal#percent
: 0 オリジン
: zero-ba......。
: 宇宙船演算子
: spaceship operator
Comparable モジュールが利用する、二つのオブジェクトの順序関係を表す
演算子 <=> の俗称。
: 埋め込みドキュメント
: embedded document
ソースコード中の =begin 行から =end 行まで。コメン......test-driven development
テストコードを先に記述してから機能を実装するプログラミング手法。
: テストファースト
: test-first programming
テスト駆動開発において、まず最初にテストコードを記述すること。
: データ型
: data type...