# Subclassing question

**URL:** <https://www.ruby-forum.com/t/subclassing-question/98510>\
**Category:** Ruby\
**Created:** [January 29, 2006, 7:13pm UTC](https://www.ruby-forum.com/t/subclassing-question/98510 "2006-01-29T19:13:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasonwold](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e36b37/32.png) [@jasonwold](https://www.ruby-forum.com/u/jasonwold)\
**Post date:** [January 29, 2006, 7:13pm UTC](https://www.ruby-forum.com/t/subclassing-question/98510/1 "2006-01-29T19:13:34Z")

</div>

I’m trying to subclass Ncurses::WINDOW but it just seems to hijack my  
class. My subclass’ initialize never gets called. I can’t add any new  
methods.

# cat test

#!/usr/bin/ruby  
begin  
require ‘rubygems’  
rescue LoadError  
ensure  
require ‘ncurses’  
end

class MyClass \< Ncurses::WINDOW

def initialize(arbstring)  
puts lkjlkdsf # this should generate an error  
end

end

Ncurses.initscr

begin  
foo = MyClass.new(10,10,0,0)  
ensure  
Ncurses.endwin  
end

puts foo.class # this should return MyClass

# ./test

=\> Ncurses::Window

Two things wrong.  
-initialize never gets called. If it did “puts lkjlkdsf” would generate  
an  
error.

-“puts foo.class” returns Ncurses::WINDOW where I would expect MyClass.

As a side note, Ncurses::WINDOW doesn’t even exist until Ncurses.initscr  
is  
called. Perhaps it’s dynamic nature is getting in the way?

Jason
