Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

(ruby) variables with colons in front

 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3076
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Ruby, an identifier that begins with a colon is a symbol.
 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. So Symbols are basically interned Strings in java.

Regards,

Pho
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pho Tek:
Thank you. So Symbols are basically interned Strings in java.

Exactly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic