> -----Original Message----- > From: Robert Mela [mailto:rmela / rcn.com] > Sent: Thursday, June 08, 2006 4:06 PM > To: ruby-talk ML > Subject: Re: Easy question > > But doesn't that result in an iteration over the points array > every time > we want to get min/max values? > Yes, which is slow, but also secure. Is there a way to remove items from your list? what happens to the minx, etc. if you remove the smallest one? suggestion: def min_x @minx ||= (@points.min{|a,b| a.x <=> b.x}).x end ... def add_point( p ) @points.push(p) @minx = @maxx = @miny = @maxy = nil end def del_point( p ) @points.delete(p) @minx = @maxx = @miny = @maxy = nil end cheers Simon