⛳Ruby 二つの値をキーに値を保存2025/12/16に公開Rubytechハッシュをネストすることで二つの値をキーに値を保存できました。 以下はインクリメントの例。 hash = Hash.new { |hash, key| hash[key] = Hash.new(0) } hash[0][1] += 1 #=> 1 hash[0][1] += 1 #=> 2 hash[0][1] += 1 #=> 3 hash[0][2] += 1 #=> 1 hash[0][2] += 1 #=> 2 hash[0][2] += 1 #=> 3 Discussion
Discussion