Bill
2007-Mar-07 07:15 UTC
[need help] what is the difference between :action => :index and :action => ''index''
i have read lots of resources about ruby symbol, but i''m still very confused about it! when i write a rails project, i can not distinguish the difference like the subject above and in fact it seems the same when browsing through two different computers , why? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Gwyn Morfey
2007-Mar-07 07:58 UTC
Re: what is the difference between :action => :index and :action => ''index''
> when i write a rails project, i can not distinguish the difference > like the subject above and in fact it seems the same when browsing > through two different computers , why?Although :index and "index" are two very different things, Rails implements something called HashWithIndifferentAccess that means you can get away with using either. It''s better to use :symbols than "strings" where you can, because a symbol is stored only once in memory, whereas a string requires an extra copy each time you refer to it. There''s an excellent explanation at http://glu.ttono.us/articles/2005/08/19/understanding-ruby-symbols . Gwyn. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bill
2007-Mar-07 09:46 UTC
Re: what is the difference between :action => :index and :action => ''index''
On 3月7日, 下午3时58分, "Gwyn Morfey" <dezyne....@googlemail.com> wrote:> > when i write a rails project, i can not distinguish the difference > > like the subject above and in fact it seems the same when browsing > > through two different computers , why? > > Although :index and "index" are two very different things, Rails > implements something called HashWithIndifferentAccess that means you > can get away with using either. > > It''s better to use :symbols than "strings" where you can, because a > symbol is stored only once in memory, whereas a string requires an > extra copy each time you refer to it. > > There''s an excellent explanation athttp://glu.ttono.us/articles/2005/08/19/understanding-ruby-symbols > . > > Gwyn.Thank you! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---