From: James Coglan Date: 2009-03-18T23:33:29+09:00 Subject: Re: Derived-class initialization --00163662e5c6762bef0465659aac Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 2009/3/18 Bryan Richardson > Hello all, > > I'm having some trouble with extending an existing Ruby class in order > to add functionality. Here's some example code: > > class Graph > .... > .... > def subgraph(*args) > graph = self.new > .... > .... > return graph > end > end This looks suspect, 'self' in this method looks like it will refer to the Graph instance, not the Graph class. Try self.class.new instead. -- James Coglan http://github.com/jcoglan --00163662e5c6762bef0465659aac--