Reputation: 2333
For example, I have file list.rb
module List
class Base
#...
end
end
So in outer files this class would be accessible as List::Base
.
Let's say I create another file list_base_extenstion.rb
I can do this:
module List
class BaseExtension < Base
#...
end
end
Or
class BaseExtension < List::Base
end
Is this equal?
Or then BaseExtension will not be considered the part of module, but inherit directly from List::Base
?
Upvotes: 1
Views: 46
Reputation: 176372
No, it's not equal. If you use
module List
class BaseExtension < Base
end
end
you define a class called List::BaseExtension
that inherits from List::Base
. Instead, with
class BaseExtension < List::Base
end
you define a class called BaseExtension
that inherits from List::Base
. The class will be defined outside the scope of List
.
Upvotes: 3