K
Kedar Mhaswade
I understand that the answer to that question is yes.
But then a singleton class (using require 'singleton') can have two or
more instances in a Ruby program, like:
require 'singleton'
class Super
include Singleton
end
class Sub < Super
end
puts Super.instance
puts Sub.instance
#=> <Super:0x000000024b5648>
#=> <Sub:0x000000024b55d0>
Doesn't this mean we have two instances of a class (Super) whose only
one instance should have been in the program (because the class included
'singleton')? IOW, shouldn't class Sub < Super be disallowed?
Thanks,
Kedar
But then a singleton class (using require 'singleton') can have two or
more instances in a Ruby program, like:
require 'singleton'
class Super
include Singleton
end
class Sub < Super
end
puts Super.instance
puts Sub.instance
#=> <Super:0x000000024b5648>
#=> <Sub:0x000000024b55d0>
Doesn't this mean we have two instances of a class (Super) whose only
one instance should have been in the program (because the class included
'singleton')? IOW, shouldn't class Sub < Super be disallowed?
Thanks,
Kedar