I am struggling to understand difference between :symbol and text: with regards to the colon placement. My understanding is that when we use :symbol we are referring to this object and whatever it contains, where as text: is used to assign a value to the text like we would a variable. Is this correct or could someone elaborate on the usage. Thank you.
I am struggling to understand difference between :symbol and text: with regards to the
Share
:whateveris a symbol, you’ve got that part right.When you’re using a hash, this was how you used to define it in 1.8x ruby:
This is known as the hashrocket syntax. In ruby 1.9x, this changed to:
There is backward compatibility that will still load the hashrocket syntax… But, in 1.9, ‘key:’ is a symbol