るりまサーチ

最速Rubyリファレンスマニュアル検索!
48件ヒット [1-48件を表示] (0.013秒)

別のキーワード

  1. strscan matched
  2. strscan matched?
  3. strscan matched_size
  4. stringscanner matched
  5. stringscanner matched?

検索結果

パターンマッチ (643.0)

パターンマッチ * patterns * variable_binding * variable_pinning * matching_non_primitive_objects * guard_clauses * current_feature_status * pattern_syntax * some_undefined_behavior_examples

..."matched"
else
"not matched"
end
#=> "not matched"
//}

一方 Hash パターン は一部のキーだけ指定している場合(指定しているキー以外にもキーが存在する場合)でもマッチします。

//emlist[][ruby]{
case {a: 1, b: 2, c: 3}
in {a: Integer}
"matched"
el...
..."not matched"
end
#=> "matched"
//}

『{}』 だけはこのルールの例外です。『{}』 は空のハッシュのみマッチします。

//emlist[][ruby]{
case {a: 1, b: 2, c: 3}
in {}
"matched"
else
"not matched"
end
#=> "not matched"
//}

//emlist[][ruby]{
case {}
in {}
"matched"
e...
...lse
"not matched"
end
#=> "matched"
//}

また、パターンで明示的に指定したキー以外のキーが存在しないハッシュにのみ、マッチさせたい場合には、『**nil』 を使います。

//emlist[][ruby]{
case {a: 1, b: 2}
in {a: Integer, **nil} # a: 以外のキ...

制御構造 (19.0)

制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END

...なパターンマッチ構文を提供しています。

//emlist[][ruby]{
case {a: 1, b: 2, c: 3}
in a: Integer => m
"matched: #{m}"
else
"not matched"
end
# => "matched: 1"
//}

パターンマッチ構文についてはspec/pattern_matchingで説明しています。

=== 繰り返し

====...

ruby 1.6 feature (7.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...= "foo"
p foo["bar"] = "baz"
p foo

=> ruby 1.6.7 (2002-03-01) [i586-linux]
"baz"
"foo"
=> -:2:in `[]=': string not matched (IndexError)
from -:2
ruby 1.6.7 (2002-07-30) [i586-linux]

: 2002-06-03 sprintf()

"%d" で引数を整数にするとき...

ruby 1.8.2 feature (7.0)

ruby 1.8.2 feature ruby 1.8.2 での ruby 1.8.1 からの変更点です。

...いる時に警告がでるようになりました。use #rest_size.
: StringScanner#matchedsize [lib] [obsolete]
$VERVOSE が設定されている時に警告がでるようになりました。use #matched_size.
: ScanError [lib] [obsolete]
use StringScanner::Error.

=== 2004-02-10

: ((<Str...