Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Example Of Detecting Subclasses

DZone's Guide to

Example Of Detecting Subclasses

·
Free Resource
class A
  def A.inherited(clazz)
    puts "Hey, #{clazz} is subclassing me"
  end
end
 
class B < A; end
 
 
Produces:
 
$ ruby x.rb
Hey, B is subclassing me
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}