Hi all
def some_method(arg)
How do I check here if arg is a constant or an object?
end
Thanks
Josh
Hi all
def some_method(arg)
end
Thanks
Josh
arg.is_a?(Class) || arg.is_a?(Module) ? “class/module” :
“object/number/whatever”
2007/10/30, Joshua M. [email protected]:
Hi –
On Tue, 30 Oct 2007, Joshua M. wrote:
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs