Mega Code Archive

 
Categories / Ruby / Hash
 

Create a hash with default value

h = Hash.new("Go Fish") h["a"] = 100 h["b"] = 200 h["a"]  100 h["c"]   # The following alters the single default object h["c"].upcase!   h["d"]   h.keys