るりまサーチ

最速Rubyリファレンスマニュアル検索!
36件ヒット [1-36件を表示] (0.030秒)
トップページ > クエリ:spec[x] > クエリ:matched[x]

別のキーワード

  1. format spec
  2. format spec=
  3. oldformat spec
  4. oldformat spec=
  5. installer spec

ライブラリ

クラス

キーワード

検索結果

パターンマッチ (23642.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...
...nspect}"
{x: @x, y: @y}
end
end

case Point.new(1, -2)
in px, Integer # パターンと変数への束縛も動きます
"matched: #{px}"
else
"not matched"
end
# "deconstruct called" と出力
#=> "matched: 1"

case Point.new(1, -2)
in x: 0.. => px
"matched: #{px}"
else
"not matched"...

制御構造 (23054.0)

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

...の右辺に置くと
syntax error になります)。

RubyはC言語やPerlから引き継いだ制御構造を持ちますが、
その他にd:spec/call#blockという
制御構造の抽象化を援助する機能があります。ブロック付きメソッド呼び出しは
繰り返しを始...
...文を提供しています。

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

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

=== 繰り返し

====[a:while] while

//emlist[...
...おいて文が存在しなかったときの値
はnilです。いずれにしてもensure節の値は無視されます。

d:spec/def#class、d:spec/def#module、d:spec/def#method
などの定義文では、それぞれ
begin なしで rescue, ensure 節を定義でき、これにより例外を...

Scanf::FormatSpecifier#matched (21101.0)

@todo

@todo

Scanf::FormatSpecifier#matched_string (9101.0)

@todo

@todo