Check if a parameter is a constant or an object?

Hi all

def some_method(arg)

How do I check here if arg is a constant or an object?

end

Thanks :slight_smile:
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