From: Paul Lutus Date: 2006-09-20T04:40:14+09:00 Subject: Re: => A newb question Dominic Son wrote: > why did matz choose to use '=>' to declare things instead of just making > them all '=' ? Umm, that isn't what '=>' does. a = b # assign b's value to a a => b # associate key a with value b > he cut our time marginally by letting us not put a ';' at the end of a > line, but now we have to put a '>' with '='... Not unless you know what it does. > (i'm gonna guess a = operator is for assigning a value, whereas a => is > for assigning symbols? ) ------------------------------------------ #!/usr/bin/ruby -w a = { "name" => "Elvis", "status" => "Left the building", "date" => 1977 } a.keys.each do |key| print "#{key} => #{a[key]}\n" end ------------------------------------------ Output: status => Left the building name => Elvis date => 1977 Note that the output order doesn't reflect the input order. -- Paul Lutus http://www.arachnoid.com