<blockqoute>
</blockqoute>
以上是原始碼,使用方式如下:
puts ['a', 'ab', 'abc', 1234].which_long?
=> 1234
授權還沒定,不過大家還是可以拿去使用:P
請不要拿掉註解.. 謝謝
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-1447561-1";
urchinTracker();
</script>
class Array
def which_long?
# Version 1.0
# Coded by CFC <>
# PLEASE DO NOT REMOVE THE COMMENT OF THIS FUNCTION, THANKS A LOT.
# Usage:
# ['a', 'ab', 'abc' 1234].which_long?
# => 1234
self.size.times{|i| self[i]=self[i].to_s}
max, long = 0, String.new
self.each{|item| item.size > max ? (max = item.size; long = item) : next}
long
end
end
</blockqoute>
以上是原始碼,使用方式如下:
puts ['a', 'ab', 'abc', 1234].which_long?
=> 1234
授權還沒定,不過大家還是可以拿去使用:P
請不要拿掉註解.. 謝謝
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-1447561-1";
urchinTracker();
</script>