Topic: session['var_name'] or session[:var_name] ?

hi!

Which form should I use to access items in hashs?
e.g.:
session['var_name'] or session[:var_name]

I know I can use both, but somewhere I read that you should use the session[:var_name] form,
because it uses less memory.
Does anybody know more about this?

Thanks
Dieter

My homepage: http://www.komendera.com/
Working at: http://www.abloom.at/
My blog: soaked and soaped http://soakedandsoaped.com/

Re: session['var_name'] or session[:var_name] ?

From my understanding, 'var_name' creates a new instance of String every time, but :var_name only creates a new instance of Symbol the first time and uses that every time you reference :var_name.

I generally stick with symbols just for convention and consistency. But, there are times when you must use a string (I think in the test cases, but I forgot exactly).

Railscasts - Free Ruby on Rails Screencasts

Re: session['var_name'] or session[:var_name] ?

Ok, thank you

My homepage: http://www.komendera.com/
Working at: http://www.abloom.at/
My blog: soaked and soaped http://soakedandsoaped.com/

Re: session['var_name'] or session[:var_name] ?

Symbols and Strings will be a lot more similar in Ruby 1.9: http://redhanded.hobix.com/inspect/Symb … tring.html

I'm really looking forward to that. Seems a symbol will just be a frozen string.

Railscasts - Free Ruby on Rails Screencasts

Re: session['var_name'] or session[:var_name] ?

And once the string is frozen, you can bang the symbol with it.