Forum: Ruby Variables starting with ":"

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5ec375630914afc5ba344322f238549b?d=identicon&s=25 Eduardo Scoz (escoz)
on 2007-01-09 22:21
Hi guys,

I've been looking for information about this for a while on some ruby
books, and tutorials, but could never find anything.

What's the diference between regular variables defined as, lets say
"example", and the ones defined as ":example" ? If there's a difference,
when should each case be used?

In many examples, it's common to see code that uses variables with the
:, specially when defining arrays (like cookies[:user_id] = "abc")..

I'm sorry for the simple/stupid question.. I've been studying about ruby
only for the last week or so.

Thanks a lot!!

Eduardo
This topic is locked and can not be replied to.