Dictionaries Are Hashes

 
   

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.


   

 

 



The Ruby Way
The Ruby Way, Second Edition: Solutions and Techniques in Ruby Programming (2nd Edition)
ISBN: 0672328844
EAN: 2147483647
Year: 2000
Pages: 119
Authors: Hal Fulton

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net