From: "Bartosz Dziewoński" Date: 2012-02-12T23:49:45+09:00 Subject: Re: the ruby syntax 2012/2/12 maven apache : > But in the ruby document:http://www.ruby-doc.org/docs/ProgrammingRuby/ > > Definiation of a hash should  like this: > > {'key'=>'value'.....} > > Now in the IO.new exmaple,it is written as {key:value}.  Is the ':' symbol > same as '=>'?? I do not find it is methioned in any document. There are two ways to define a hash. First is, as you are saying, {key => value}, where both key and value can be anything. {'key' => 'value'} is okay (key and value are strings), but for example this is also valid: { [1,2] => {3 => 4} } (here key is an array, value is another hash). The second way, introduced in Ruby 1.9, is {key: value}. Value is still an arbitrary Ruby value, but the key is converted to a Symbol - so this: {key: value} is equivalent to this: {:key => value}. The second method is less typing, so it's more often used now, when you don't care about compatibility with Ruby 1.8, and you are fine with your keys all being symbols. You can also mix both styles in a single hash definition. -- Matma Rex