I was researching an earlier issue with rails and I stumbled across a document which mentioned something that sounded to me like "Due to a recent shift in the mind-set of the community, it is frowned upon to use a string literal in any situation which does not require text manipulation; use symbols instead." Did I interpret the info on that page correctly? Also, any further info you can give me about when I should be using literals and when to use symbols would be very much appreciated. Also, any other tips on best-practice or links to good resources about such would be rad. -Kyle --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> I was researching an earlier issue with rails and I stumbled across a > document which mentioned something that sounded to me like "Due to a > recent shift in the mind-set of the community, it is frowned upon to > use a string literal in any situation which does not require text > manipulation; use symbols instead." Did I interpret the info on that > page correctly?No idea, since I don''t know what page you''re referring to, but it sounds reasonable. One reason to use symbols is that there is only *one* :foo, but there are many "foo"''s. That is... >> :foo.object_id => 146098 >> "foo".object_id => 1750540 >> :foo.object_id => 146098 >> "foo".object_id => 1734530 >> def foomethod >> :foo.object_id >> end => nil >> foomethod => 146098 Notice how the id of :foo never changes -- even inside methods? But the id of "foo" does change. So :foo is cheaper as there is only one in existence in the entire program memory.> Also, any further info you can give me about when I should be using > literals and when to use symbols would be very much appreciated. > Also, any other tips on best-practice or links to good resources about > such would be rad. > > -Kyle > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Josh Susser says Symbols are not pretty strings - http://tinyurl.com/4sqwt9 On Jul 23, 12:41 pm, A Love of Surf <wetl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I was researching an earlier issue with rails and I stumbled across a > document which mentioned something that sounded to me like "Due to a > recent shift in the mind-set of the community, it is frowned upon to > use a string literal in any situation which does not require text > manipulation; use symbols instead." Did I interpret the info on that > page correctly? > Also, any further info you can give me about when I should be using > literals and when to use symbols would be very much appreciated. > Also, any other tips on best-practice or links to good resources about > such would be rad. > > -Kyle--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---