There is a shorthand way of creating Hashes and initializing them with key-value pairs.
Just add a key followed by => and its associated value.
Each key-value pair should be separated by a comma and the whole lot placed inside a pair of curly brackets:
h1 = {'room1'=>'A', 'room2'=>'B', 'loc1' =>'C', 'loc2' =>'D' } puts h1# from ww w . j ava 2 s. c o m