Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #4077

Re: Cross access between instance variables

From Stefan Salewski <mail@ssalewski.de>
Newsgroups comp.lang.ruby
Subject Re: Cross access between instance variables
Date 2011-05-07 16:27 -0500
Organization Service de news de lacave.net
Message-ID <1304803573.3606.7.camel@AMD64X2.fritz.box> (permalink)
References <1304622204.2610.22.camel@AMD64X2.fritz.box> <92hpeiFe2mU1@mid.dfncis.de>

Show all headers | View raw


On Fri, 2011-05-06 at 17:25 +0900, Johannes Held wrote:
> On 05.05.2011 21:06, Stefan Salewski wrote:
> > But now we really need many tanks, each with very many fishes.
> > Currently it seems to be a bit strange giving each of thousands
> > fishes a reference to its tank.
> You can control the fishes within the tank. Every fish is saved in an 
> array in tank. The tank queries every fish for it's mood …
> 
> http://pastie.org/1870880
> 
> > Another solution may be to give the .tell_state() function a tank
> > parameter each time when we call it. (A tank-temperature parameter
> > is not a good idea, because we may need more, light, food...)
> Why not? Pass them via a hash?
> IMO there's no need for a fish to know its tank.
> 
> 
> --
> Johannes
> 

Thank you for your example.
Of course this is a way to solve the problem. It may look not very
natural, that we have to tell the fish the parameters of its tank, when
we ask the fish about its mood:

>mood =  fish.tell_mood({:temp => t.temp, :food => t.food_type})

But OK, this is the way to do it. Now I know that I have not missed
something.

Thanks

Stefan Salewski


Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Cross access between instance variables Stefan Salewski <mail@ssalewski.de> - 2011-05-05 14:06 -0500
  Re: Cross access between instance variables Josh Cheek <josh.cheek@gmail.com> - 2011-05-05 14:47 -0500
  Re: Cross access between instance variables Johannes Held <johannes.held@informatik.uni-erlangen.de> - 2011-05-06 10:23 +0200
    Re: Cross access between instance variables Stefan Salewski <mail@ssalewski.de> - 2011-05-07 16:27 -0500
      Re: Cross access between instance variables Hassan Schroeder <hassan.schroeder@gmail.com> - 2011-05-07 18:27 -0500
        Re: Cross access between instance variables John Feminella <johnf@bitsbuilder.com> - 2011-05-07 18:36 -0500
          Re: Cross access between instance variables Hassan Schroeder <hassan.schroeder@gmail.com> - 2011-05-07 19:31 -0500
            Re: Cross access between instance variables John Feminella <johnf@bitsbuilder.com> - 2011-05-07 19:51 -0500

csiph-web