Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

(ruby) variables with colons in front

 
Ranch Hand
Posts: 782
Python Chrome 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
 
Master Rancher
Posts: 3518
37
  • 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
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. So Symbols are basically interned Strings in java.

Regards,

Pho
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • 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.
 
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic