From: David Alan Black Date: 2002-06-22T06:30:19+09:00 Subject: Re: Looking for the Ruby way for the following Hello -- On Sat, 22 Jun 2002, Bil Kleb wrote: > Currently I am using the following rather ugly bit of Ruby code > to calculate the maximum length of the file names strings (plus one) > in the array file_list, > > fn_width = 0 > file_list.each{ |fn| fn_width = [File.basename(fn).size, fn_width].max } > fn_width += 1 > > Can someone offer a more elegant method? My brain seems to have shutdown > on this problem today... You could do: fn_width = file_list.map {|f| File.basename(f).size}.max + 1 David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav