For Programmers: Free Programming Magazines  


Home > Archive > Ruby > August 2005 > Re: Circular dependecy on classes









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Circular dependecy on classes
David A. Black

2005-08-28, 6:59 pm

Hi --

On Fri, 26 Aug 2005, Robert Klemme wrote:

> 2005/8/26, Derek Wyatt <derek@derekwyatt.org>:
>
> Doesn't solve the OP'S problem because it was about dependencies:
> Knight has to be defined when it is used.


As long as it's defined before the method is called it should be OK:

class C
def can_upgrade_to
[D]
end
end

class D
end

p C.new.can_upgrade_to[0].new # #<D:0x401c0db8>


David

--
David A. Black
dblack@wobblini.net


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com