Mega Code Archive

 
Categories / Ruby / Hash
 

Creating a Hash with a Default Value

h = Hash.new("nope") p h[1]                                           # => "nope" p h['do you have this string?']                   # => "nope"