Jacob Fugal wrote:
> On 7/4/05, Robert Klemme <bob.news / gmx.net> wrote:
>>
>> class Foo
>>   def Foo.bar1() "bar1" end
>>
>>   def self.bar2() "bar2" end
>>
>>   class <<self
>>     def bar3() "bar3" end
>>   end
>>
>>   class <<Foo
>>     def bar4() "bar4" end
>>   end
>> end
>
> Note that the last form (class << Foo) doesn't need to be inside the
> reopened class:
>
>   $ cat > a.rb
>   class Foo; end
>
>   class << Foo
>     def test
>       puts "Hello, world!"
>     end
>   end
>
>   Foo.test
>
>   $ ruby a.rb
>   Hello, world!

The same is true for variant 1 also.  I prefer the nested versions with
"self" because they are immune to name changes of the class.

Kind regards

    robert