The Ruby Way, Second Edition: Solutions and Techniques in Ruby Programming (2nd Edition)

 

   

Ruby Way

By Hal Fulton

Slots : 1.0

Table of Contents
 

Use => instead of : to indicate pairings in a hash. Hash keys can be mutable objects (see rehash). Inverting a hash does not automatically group duplicates into an array; you will lose entries if there were duplicate values.

hsh = { } hsh['key'] = 7 hsh2 = { "A"=>65, "B"=>66 }

Ruby supports default values for hashes.


   
 

Категории