るりまサーチ

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

別のキーワード

  1. strscan rest
  2. strscan rest?
  3. stringscanner rest
  4. strscan rest_size
  5. stringscanner rest?

ライブラリ

クラス

キーワード

検索結果

CSV::Row#deconstruct -> [object] (18113.0)

パターンマッチに使用する行の値の配列を返します。

...3])
case row
in [2.., 2.., 2..]
puts "all 2 or more"
in [...2, 2.., 2..]
puts "first column is less than 2, and rest columns are 2 or more"
end
#=> "first column is less than 2, and rest columns are 2 or more" が出力される
//}

@see d:spec/pattern_matching#matching_non_primitive_objects...

CSV::Row#deconstruct_keys(keys) -> Hash (6113.0)

パターンマッチに使用するヘッダの名前と値の Hash を返します。

.... }
puts "all 2 or more"
in { header1: ...2, header2: 2.., header3: 2.. }
puts "first column is less than 2, and rest columns are 2 or more"
end
#=> "first column is less than 2, and rest columns are 2 or more" が出力される
//}

@see d:spec/pattern_matching#matching_non_primitive_objects...

パターンマッチ (192.0)

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

...ンをネストさせることができます。

Array パターン は配列か deconstruct メソッド(後述)を持つオブジェクトにマッチします。

Hash パターン はハッシュか deconstruct_keys メソッド(後述)を持つオブジェクトにマッチします。Hash パ...
...に束縛できます。

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

//emlist[][ruby]{
case {a: 1, b: 2, c: 3}
in a:, **rest
"matched: #{a}, #{rest}"
else
"not matched"
end
#=> "matched: 1, {:b=>2, :c=>3}"
//}...
...(これは、変数への束縛の機能を実現するための制限です。)

//emlist[][ruby]{
expectation = 18

case [1, 2]
in expectation, *rest
"matched. expectation was: #{expectation}"
else
"not matched. expectation was: #{expectation}"
end
# 期待する動作:"not matched. expectat...
...ることができます。

Array パターン と Find パターン は配列か deconstruct メソッド(後述)を持つオブジェクトにマッチします。

Hash パターン はハッシュか deconstruct_keys メソッド(後述)を持つオブジェクトにマッチします。Hash...