# Re: final/closed classes in Ruby (was: Sharp knives and glue

**URL:** <https://www.ruby-forum.com/t/re-final-closed-classes-in-ruby-was-sharp-knives-and-glue/94737>\
**Category:** Ruby\
**Created:** [May 12, 2006, 4:07pm UTC](https://www.ruby-forum.com/t/re-final-closed-classes-in-ruby-was-sharp-knives-and-glue/94737 "2006-05-12T16:07:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [May 12, 2006, 4:07pm UTC](https://www.ruby-forum.com/t/re-final-closed-classes-in-ruby-was-sharp-knives-and-glue/94737/1 "2006-05-12T16:07:27Z")

</div>

> -----Original Message-----  
> From: Logan C. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
> Sent: Thursday, May 11, 2006 5:18 PM  
> To: ruby-talk ML  
> Subject: Re: final/closed classes in Ruby (was: Sharp knives and glue)

> Unfortunately, it raises an exception way too late.

Too late for whom? Yes, you can get around it, but you have to go out  
of your way to do so.

Dan

This communication is the property of Qwest and may contain confidential  
or  
privileged information. Unauthorized use of this communication is  
strictly  
prohibited and may be unlawful. If you have received this communication  
in error, please immediately notify the sender by reply e-mail and  
destroy  
all copies of the communication and any attachments.

---

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [May 12, 2006, 9:45pm UTC](https://www.ruby-forum.com/t/re-final-closed-classes-in-ruby-was-sharp-knives-and-glue/94737/2 "2006-05-12T21:45:00Z")

</div>

On May 12, 2006, at 10:05 AM, Berger, Daniel wrote:

> of your way to do so.  
> in error, please immediately notify the sender by reply e-mail and  
> destroy  
> all copies of the communication and any attachments.

I’m defining too late as ‘after the damage has been done’, e.g. Bar  
has already been sub-classed. I guess it comes down to a question of  
does final mean no sub-classes can be created, or no sub-classes can  
be used? If it means the first, than yes it is too late. I think that  
the distinction is especially important in Ruby because we do have  
these #inherited style hooks, and inheriting from something can  
cause all sorts of side effects (e.g. activerecord). If someone does  
something like

class A \< SomeClassFullOfDeepMagic  
final # don’t want any subclasses of A  
end

class B \< A  
end

and expects it to work, they may be in for a rude surprise, since the  
deep magic may still happen, despite the fact that an exception is  
raised.
