[Rails] Re: A Good Tutorial on Params and Variables

Brian Hughes
2006-04-30T05:13:01Z

On Apr 30, 2006, at 12:59 AM, Ted Battreall wrote:
> I am still a little fuzzy on the syntax as I see different syntax all
> ofver the place. What is the difference between?
>
> session[''user'']
> and
> @session[''user'']
> and
> session[:user]

No need for confusion here. All three of these are currently the
same, although the middle form, using @session, has been deprecated
in favor of calling the session method.

Most Rubyists will use the third form, as using symbols in this way
is more efficient than strings, and it just looks better when you
read the source code. In fact, the only time I would use the first
form is when the key I want to reference starts with a digit, instead
of a letter. Symbols can''t start with digits.

-Brian