Glenn Parker ha scritto:
> John-Mason P. Shackelford wrote:
> 
>> In ruby is it possible to have a private innner class? Using private 
>> method doesn't appear to work.
>>
>> class A
>>   private
>>   class B
>>     def hw
>>       'hello_world'
>>     end
>>   end
>> end
>>
>> A::B.new.hw  # => 'hello world'
> 
> 
> p A::B.new.hw => "hello world"
> 

I guess he meant this is not private.
Anyway, that would be a "yes and no". You can't do that way since 
constants are public, but you can use a class variable, wich is private:

 >> class External
 >>  @@private_class = Class.new do
?>   def foo
 >>    'yuk'
 >>   end
 >>  end
 >>  def gimme_an_object
 >>   @@private_class.new
 >>  end
 >> end
=> nil
 >> External.new.gimme_an_object.foo()
=> "yuk"