I found this in many rails source codes: string[:symbol] <pre>''Some string''[:some_symbol'']<pre> Can someone tell me what it stands for? Thks -- 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 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 -~----------~----~----~----~------~----~------~--~---
Faisal N Jawdat
2007-Sep-01 22:43 UTC
Re: Newbie question: what does string[:symbol] mean?
This is likely a Haah reference -- the string is the name of the Hash object, and the symbol within is a key. For more on symbols, see: http://glu.ttono.us/articles/2005/08/19/understanding-ruby-symbols -faisal On Sep 1, 2007, at 6:39 PM, Wahid Lahlou wrote:> I found this in many rails source codes: string[:symbol] > <pre>''Some string''[:some_symbol'']<pre> > Can someone tell me what it stands for? > > Thks > -- > 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 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 -~----------~----~----~----~------~----~------~--~---
Thanks Faisal, I read almost all you can find about symbols and the string class, but I couldn''t find how this must be helpful. For example, in the Beast forum source code, a lot of messages in the rhtml files are writen this way: <h5><%= ''What is Beast?''[:beast_sidebar_title]%></h5> or <%= ''A small, light-weight forum in Rails with a scary name and a goal of around 500 lines of code when we\''re done.''[:beast_sidebar_body] %> Is it something related to localization? Or can you access something with this symbol? -- 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 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 -~----------~----~----~----~------~----~------~--~---
Chris Wanstrath
2007-Sep-01 23:00 UTC
Re: Newbie question: what does string[:symbol] mean?
On 9/1/07, Wahid Lahlou <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I read almost all you can find about symbols and the string class, but I > couldn''t find how this must be helpful. For example, in the Beast forum > source code, a lot of messages in the rhtml files are writen this way: > <h5><%= ''What is Beast?''[:beast_sidebar_title]%></h5> > or > <%= ''A small, light-weight forum in Rails with a scary name and a goal > of around 500 lines of code when we\''re done.''[:beast_sidebar_body] %> > > Is it something related to localization? Or can you access something > with this symbol?Yup, localization. Beast uses the Gibberish plugin to this end. http://errtheblog.com/post/4396 -- Chris Wanstrath http://errfree.com // http://errtheblog.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---