🖥
Ruby - ハッシュの初期値を配列にする
example_hash = Hash.new{|hash, key| hash[key] = []}
ハッシュの要素にいきなり配列としてpush出来たりする
example_hash["foo"].push "bar"
example_hash # => {"foo"=>["bar"]}
参考
チャットメンバー募集
何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。
公開日時
2022-08-02
example_hash = Hash.new{|hash, key| hash[key] = []}
ハッシュの要素にいきなり配列としてpush出来たりする
example_hash["foo"].push "bar"
example_hash # => {"foo"=>["bar"]}
何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。
2022-08-02
Discussion