Ben Lovell
5/25/2009 5:28:00 PM
[Note: parts of this message were removed to make it a legal post.]
On Mon, May 25, 2009 at 6:19 PM, Mk 27 <halfcountplus@intergate.com> 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?
The first example is indexing via a string, the second is via a ruby symbol.
You can think of a symbol as essentially a (very) lightweight string usually
used for keying into hashes and general naming of things.
Rgds,
Ben