I found this in many rails source codes: string[:symbol]
'Some string'[:some_symbol']Can someone tell me what it stands for? Thks
I found this in many rails source codes: string[:symbol]
'Some string'[:some_symbol']Can someone tell me what it stands for? Thks
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
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:
Is it something related to localization? Or can you access something
with this symbol?
On 9/1/07, Wahid L. [email protected] 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:<%= 'What is Beast?'[:beast_sidebar_title]%>
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 W.
http://errfree.com // http://errtheblog.com
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs