# Reopen a class and inheritance

**URL:** <https://www.ruby-forum.com/t/reopen-a-class-and-inheritance/128872>\
**Category:** Ruby\
**Created:** [February 12, 2008, 10:20am UTC](https://www.ruby-forum.com/t/reopen-a-class-and-inheritance/128872 "2008-02-12T10:20:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pachl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5f9b8f/32.png) [@pachl](https://www.ruby-forum.com/u/pachl)\
**Post date:** [February 12, 2008, 10:20am UTC](https://www.ruby-forum.com/t/reopen-a-class-and-inheritance/128872/1 "2008-02-12T10:20:48Z")

</div>

Is it recommended to include the parent class when reopening a child  
class? What are the consequences of each?

class Parent  
def meth0; ‘meth0’ end  
end

class Child \< Parent  
def meth1; ‘meth1’ end  
end

# Reopen class w/o parent

class Child  
def meth2; ‘meth2’ end  
end

# Reopen class w/ parent

class Child \< Parent  
def meth3; ‘meth3’ end  
end

---

<div class="post-metadata">

**Author:** ![pachl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5f9b8f/32.png) [@pachl](https://www.ruby-forum.com/u/pachl)\
**Post date:** [February 12, 2008, 10:46am UTC](https://www.ruby-forum.com/t/reopen-a-class-and-inheritance/128872/2 "2008-02-12T10:46:06Z")

</div>

> Is it recommended to include the parent class when reopening a child  
> class?

If you change the parent class (for whatever reason that might be),  
you’ll also have to change all locations where the child class is  
opened.

IIRC it was once discussed that adding the child class makes added  
methods be stacked instead of overwritten. I hope this won’t be  
included in future versions of ruby due to its cryptic style but there  
is a possibility these two versions will behave differently some day  
in the future.
