This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Ruby and the fly likes (ruby) variables with colons in front Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Languages » Ruby
Bookmark "(ruby) variables with colons in front" Watch "(ruby) variables with colons in front" New topic
Author

(ruby) variables with colons in front

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

Are there any specific convention with regards to variable naming in Ruby?

I was looking at some rake tasks and was led to believe that their names have a colon in front because it is an internal DSL (according to Fowler).

Then I took a look at this; and variables with colon prefixes are everywhere.

Please enlighten me.

Thanks

Pho
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3011
    
  10
In Ruby, an identifier that begins with a colon is a symbol.
Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

Thank you. So Symbols are basically interned Strings in java.

Regards,

Pho
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Originally posted by Pho Tek:
Thank you. So Symbols are basically interned Strings in java.

Exactly.


A good workman is known by his tools.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: (ruby) variables with colons in front