On Sep 26, 2004, at 9:24 AM, Florian Gross wrote:

> Moin!
>
> Here's my solution for the Solitaire Cipher quiz. It's fairly 
> class-oriented and longish.

Help.  <laughs>  I'm trying to figure this code out...

> module Solitaire
>   extend self

# snip module definition...

> end

I'm trying to understand the above trick:

extends self

would be the same as:

self.extends self

Which just leaves the question of what is self?  Obviously, it has to 
be the module itself.  That means we added the methods to the module 
itself?

That doesn't make sense alone;  however, I know extending a module in 
in a class definition adds the module methods as class methods.  If I 
assume the same is happening here...

My guess:  You duplicated all of Solitaires' methods as class methods?

If I'm right, you could have done the same by declaring all those 
methods as:

def Solitaire.<method_name>...

Right?

Hmm, wait.  Not quite.  Then you would be missing the instance methods.

So why did you write it this way?

Big Guess (really reaching now):  To provide a convenient interface to 
use the module stand-alone while also allowing it to be mixed into 
future creations?

Thanks for the lesson.

James Edward Gray II