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, Anatol Pomozov wrote:

> Thanks for your quick answers.
>
> Somewhere (i did not remember) I saw following trick
>
> def Soldier
> @can_upgrade_to = [:Knight] #This list != list of all ancestors
>
> def upgrade?(to)
> @can_upgrade_to.include?(to.to_s.to_sym)
> end
> end
>
> but the solution provided by Derek seems more natural for me.


And it has the advantage of working :-) What you've got above (even
given that you mean class rather than def) does not work. (See my
earlier post.)


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