Check if a parameter is a constant or an object?

J

Joshua Muheim

Hi all

def some_method(arg)
# How do I check here if arg is a constant or an object?
end

Thanks :)
Josh
 
D

David A. Black

Hi --

Hi all

def some_method(arg)
# How do I check here if arg is a constant or an object?
end

Constants are bound to objects:

X = "hi"
some_method(X)

The method just receives an object reference. It doesn't actually
receive a constant; the constant is just an identifier.

(Or am I misunderstanding?)


David

--
Upcoming training by David A. Black/Ruby Power and Light, LLC:
* Advancing With Rails, Edison, NJ, November 6-9
* Advancing With Rails, Berlin, Germany, November 19-22
* Intro to Rails, London, UK, December 3-6 (by Skills Matter)
See http://www.rubypal.com for details!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,813
Messages
2,569,696
Members
45,481
Latest member
Arnulfo32P

Latest Threads

Top