Problem with inner classes


(Francis Hwang) #1

Arg, another newbie mistake. It turns out that the problem didn’t
have much to do with inner classes at all: One of the inner class
files didn’t have the necessary require so it thought it had to
define the outer class anew, and then that got entangled with some
inheritance. The long and short of it is that I added one "require"
statement and that fixed the problem. Sorry 'bout that.

This is one of the downsides of having a very flexible language, I
suppose; since the interpreter has less information regarding your
intent, it can’t be as helpful with its error messages. Overall, Ruby
is still my favorite language, even if I keep making strange newbie
mistakes with it.

To answer K’s question: I’m using that many inner classes for the
same reason you might put them in a module. To limit the namespace. I
don’t see much of a difference between a module and an outer class,
anyway. The Pickaxe book says that a module is basically an outer
class that can’t be instantiated, which seems sensible to me.

Francis