This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread 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


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: 776

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: 3027
    
  10
In Ruby, an identifier that begins with a colon is a symbol.
Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 776

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: (ruby) variables with colons in front
 
It's not a secret anymore!