From: Billy Hsu Date: 2007-04-29T22:44:50+09:00 Subject: Array.which_long? ( I coded an extension for Array ) ------=_Part_1626_15824358.1177854288708 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, I'm CFC I'm new at here. Nice to meet you:) I just coded an extension for Array. It will return the longest element of an array. Source: class Array def which_long? # Version 1.0 # Coded by CFC < zusocfc @ gmail . com > # PLEASE DO NOT REMOVE THE COMMENT OF THIS FUNCTION, THANKS A LOT. # Usage: # ['a', 'ab', 'abc' 1234].which_long? # => 1234 max, long, self_cpy = 0, "", [] self.size.times{|i| self_cpy << self[i].to_s} self_cpy.each{|item| (max = item.size; long = item) if item.size > max } long end end Usage: puts [1, 23, '456'].which_long? => 456 CFC -- ------=_Part_1626_15824358.1177854288708--