Help us understand the problem. What is going on with this article?

#Ruby nested class and module pattern : child class or module not overwrite parent class or module : but able to define it

```rb
# A is class

class A
end

A.class
# => Class



# A is class and B is class

class A::B
end

A.class
# => Class

A::B.class
# => Class


# A is class but C is module

module A::C
end

A.class
# => Class

A::B.class
# => Class

A::C.class
# => Module

A::C.ancestors
# => [A::C]


# Unable to replace class to module or module to class


module A
end
# TypeError: A is not a module

module A::B
end
# TypeError: B is not a module

class A::C
end
# TypeError: C is not a class



# when Module is parent pattern

module D
end

module D::E
end

class D::F
end

D.class
# => Module

D::E.class
# => Module

D::F.class
# => Class

# Original by Github issue

https://github.com/YumaInaura/YumaInaura/issues/2827
YumaInaura
Ruby on Rails 業務経験 約5年 / Perl PHP Python Golang Linux Apache MySQL BigQuery Jenkins ansible AWS など / いなうらゆうま / YumaInaura / 稲浦悠馬
http://twitter.com/yumainaura
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away