From: Tim Hunter Date: 2009-05-26T02:26:04+09:00 Subject: Re: hash assignment [:x] vs ['x'] Mk 27 wrote: > Being totally new to ruby, I just noticed that using > > bob['phone'] > > which coming from perl is a style I'm used to, results in a separate key > than > > bob[:phone] > > That seems slightly weird, I had assumed the :form is just a shorthand > like %w( ). So -- is there anything more that I need to understand > about this distinction? :x is a Symbol object. 'x' is a String. You can make a symbol from a string with the intern method, and a string from a symbol with the to_s method. A symbol is a named number that Ruby guarantees will have the same value throughout your program. You pick the name, Ruby picks the number. -- RMagick: http://rmagick.rubyforge.org/