I am playing around with nested classes.
I tried the following:
class A
private
class B
def f
puts "f"
end
end
def u
end
@x
public
def initialize
@x = B.new
end
end
b = A::B.new
b.f
a = A.new
a.u
The result is that it raises an exception for the last line
of the code.
The principle of least surprise would suggest that the
b = A::B.new
already fails, since B is a private class in A.
Is there a way at all to hide some member class of a class
in Ruby?