From: Phrogz Date: 2007-02-08T05:20:07+09:00 Subject: Re: Algorithm Help - Grid Space Calculations 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]