From: Martin DeMello Date: 2007-02-08T05:27:19+09:00 Subject: Re: Algorithm Help - Grid Space Calculations On 2/8/07, Phrogz wrote: > On Feb 7, 1:13 pm, "Martin DeMello" wrote: > > That was where I really missed the oft-requested min_by: > > > > $grid_spacing = [high, low].min_by {|i| ($grid_spacing - i).abs} > > > > but I felt defining it for that one use would be overkill :) > > Though it would be computationally inefficient compared to what it > could be, you could of course get the same functionality with: > [high,low].sort_by{ |i| ($grid_spacing-i).abs }[0] True, but it would hurt to do that :) martin