From: Dave Howell Date: 2010-07-22T15:00:20+09:00 Subject: Re: Return nothing when looking outside the bounds of 2D array? On Jul 20, 2010, at 22:00 , Shawn W_ wrote: > Shawn W_ wrote: > > I think I got it. I did away with storing my cell data in a hash; rather > I will put an array in each cell of the 2D array, and add another > parameter to the def [] and def []= methods to access it. I don't recommend scrapping working code, but in the future, you might want to think about doing something a little more ruby-flavored. Something like, oh, maybe this.... def HexCell < Array blah blah end ary = HexArray(3,4) => (Array of HexCells) >>ary[2,3].neighbor(:upperleft) => HexCell at [2,2] Delta would be defined like this: Delta={:center => [0,0], :upperright => [0.5,-1], :right => [1,0], :lowerright => [0.5,1], :lowerleft => [-0.5,1], :left => [-1,0], :upperleft => [-0.5,-1]]