943,917 Members | Top Members by Rank

Ad:
  • Ruby Discussion Thread
  • Unsolved
  • Views: 2495
  • Ruby RSS
Jun 4th, 2009
0

Names starting with ":"

Expand Post »
What are names starting with the ":", are they variables, constants or something else?

drjay
Similar Threads
Reputation Points: 12
Solved Threads: 1
Junior Poster in Training
drjay1627 is offline Offline
87 posts
since Nov 2008
Jun 5th, 2009
0

Re: Names starting with ":"

Click to Expand / Collapse  Quote originally posted by drjay1627 ...
What are names starting with the ":", are they variables, constants or something else?

drjay
In ruby if you don't know what class an object is you can use it's class method and the docs to find out.

ruby Syntax (Toggle Plain Text)
  1. % irb --simple-prompt
  2. >> a = :something
  3. => :something
  4. >> a.class
  5. => Symbol

Then look it up in the docs: http://www.ruby-doc.org/core/classes/Symbol.html
Last edited by pty; Jun 5th, 2009 at 4:00 pm.
pty
Reputation Points: 64
Solved Threads: 39
Posting Pro
pty is offline Offline
530 posts
since Oct 2005
Jun 12th, 2009
0

Re: Names starting with ":"

They are called 'symbols' in Ruby.
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006
Jul 23rd, 2009
0

Re: Names starting with ":"

names starting with ":" are expressions that return a symbol object e.g.
Ruby Syntax (Toggle Plain Text)
  1. Class Person
  2. attr_reader :name, :age, :sex
  3. end
  4.  
  5. me = Person.new("poison", "24", "male")

The construct :name is an expression that returns a symbol corresponding to name.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Kevin_poison is offline Offline
1 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Ruby Forum Timeline: Starting up with Ruby on Rails..
Next Thread in Ruby Forum Timeline: Domain Name Checker





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC