Help with object scope

L

List Recv

I'm having a really tough time with Ruby's scope (modules, include,
etc.).

I had a file, in short:

module M
class C
end
end

# Unit Tests
include M
class TestM
def setup; C.blah; end
end

Works great.

*However*, if I wrap the unit tests in their own module, then ruby can
no longer find class C. Why? Didn't I include module M? I'm really
confused here.

If you want the full source, I can post it.

Thanks
PS If you could also direct me to a good link explaining this stuff, I'd
really appreciate it. I have to say that I don't know Ruby's exact
definition of a module. I know it is a namespace, but it seems to be
more than that (as evidenced by the fact that it has methods, and can be
mixedin, and the like).
 

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

Scope 3
Python battle game help 2
Help with code 0
Selenium c++ help 0
Help please 8
Need Help with Windows.Forms in VS (C#) 0
Scope Missunderstanding 3
scope when reopening method 3

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,147
Latest member
CarenSchni
Top