15件ヒット
[1-15件を表示]
(0.056秒)
別のキーワード
検索結果
-
CSV
:: Row # deconstruct _ keys(keys) -> Hash (18113.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... -
パターンマッチ (132.0)
-
パターンマッチ * patterns * variable_binding * variable_pinning * matching_non_primitive_objects * guard_clauses * current_feature_status * pattern_syntax * some_undefined_behavior_examples
...ーン は配列か 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...