Robert Mela wrote: > def add_point( p ) > @points.push(p) > if !@minx || @minx > p.x > @minx=p.x > end > if .... @points is an array of arrays, right? def add_point(p) @points.push(p) @max_x = @points.inject{|max, cur| cur[0] > max[0] ? cur : max}[0] @min_x = @points.inject{|min, cur| cur[0] < min[0] ? cur : max}[0] @max_y = @points.inject{|max, cur| cur[1] > max[1] ? cur : max}[1] @min_y = @points.inject{|min, cur| cur[1] < min[1] ? cur : max}[1] end Depending on how often you update the array, and how often you want the min/max values, you ought to consider putting each #inject in its own method instead: def max_x @points.inject{|max, cur| cur[0] > max[0] ? cur : max}[0] end Cheers, Daniel