From: Harry Date: 2007-04-30T07:14:17+09:00 Subject: Re: Array.which_long? ( I coded an extension for Array ) On 4/29/07, Billy Hsu wrote: > Thanks for your reply, I learned more on this thread :P > But I have a question: > If I have an array contain: > ary = [1, 12, 234, "456"] > there has two elements which size is 3, but the longest method just returned > one of them. > I can't solve it :( > Is this what you are looking for? Do you want all longest elements? big = [1, 12, 234,45,978, "456"].max {|x,y| x.to_s.size <=> y.to_s.size} p [1, 12, 234,45,978, "456"].select {|r| r.to_s.size == big.to_s.size} Harry -- http://www.kakueki.com/ruby/list.html A Look into Japanese Ruby List in English