const_missing oddity?

P

Phil Tomson

def Object.const_missing name
puts "There is no constant: #{name}"
end

irb(main):038:0> Foo { puts "here!"}
NoMethodError: undefined method `Foo' for main:Object
from (irb):38
from :0

irb(main):039:0> Foo
There is no constant: Foo
=> nil

So the block after Foo keeps Foo from being recognized as a constant?
(apparently it's recognized as a method instead)

Phil
 

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,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top