From: James Edward Gray II Date: 2004-09-24T06:47:45+09:00 Subject: Re: Newbie: Case statement On Sep 23, 2004, at 4:34 PM, Warren Brown wrote: > Graham, > > You can save yourself an enormous number of headaches by simply > adding two more rows and columns to your array. For example, if you > wanted the world to be 80x24, make your array 82x26 and then make your > loops from 1..80 and 1..24. That way you can safely reference > cell[x-1][y-1] and cell[x+1][y+1] and you don't need all of your > special > cases. I'm aware this is a common approach, but I'm personally not found of it. First of all, it confuses readers of the code. What size board are we really dealing with here? Why do these loops keep starting at 1 instead of 0? Second, it almost always still requires special cases. For example, in the mentioned Game of Life, we must be sure organisms are not born into these border rows, or they'll change the results. Finally, it's wasteful. I realize the memory is insignificant here, but it might not be in a bigger application. My opinion is that it's better to address the real issue than just hide it away. James Edward Gray II