const_missing

H

Hal E. Fulton

I just tried to use const_missing (which I think is a
neat idea).

Shouldn't it work at the top level? Am I doing something
wrong?

def const_missing
"not found"
end

p FOO

The above gives an error.

Hal
 
C

Christoph R.

Hal said:
I just tried to use const_missing (which I think is a
neat idea).

Shouldn't it work at the top level? Am I doing something
wrong?

def const_missing
"not found"
end

This should be

---
def Object.const_missing(sym)
p sym
end

Foo
 
C

Christoph R.

Hal E. Fulton wrote:

....
The above gives an error.


On second thought your implementation could
have worked - the following may sheet more light
(confusion in my case;-) on it ...

--
def const_missing(sym)
p sym
end

def const_missingx(sym)
p sym
end

public :const_missing,:const_missingx
Object.const_missingx:)K) # :K
Object.const_missing:)K) # throws a NameError ???
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top