One reason to use Symbols is that they are immutable. When you're 
passing one around as an argument or Hash key, it won't change.
Another is that multiple instances of a Symbol are the same object, 
making a smaller memory footprint than Strings.

A string is not a symbol. Some structures will use to_s or to_sym to 
allow you to pass either as an argument, but that's not their default 
behaviour.

> {'a'=>1,:a=>2}
=> {"a"=>1, :a=>2}

> {'a'=>1,'a'=>2}
=> {"a"=>2}

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/34b316ac9098fe1cc8a7e07ed2413388%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to