frozen is kept in variable assignment but not converting : freeze « Hash « Ruby






frozen is kept in variable assignment but not converting


hash = { 1 => 1, 2 => 4, 3 => 9 }
hash.freeze
arr = hash.to_a
puts hash.frozen?                   # true
puts arr.frozen?                    # false
hash2 = hash
puts hash2.frozen?                  # true

 








Related examples in the same category