Answers for "ruby hash with default value"

0

ruby hash with default value

hash = Hash.new(:default_value)
hash[:foo] = 'bar'
hash[:foo] #=> 'bar'
hash[:inexistent] #=> :default_value
Posted by: Guest on April-20-2022
0

ruby hash with default value

hash = { foo: 'bar' }
hash.default = :default_value
hash[:foo] #=> 'bar'
hash[:inexistent] #=> :default_value
Posted by: Guest on April-20-2022

Browse Popular Code Answers by Language