summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-03-22 16:47:56 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-03-22 16:47:56 +0900
commitebb337b132a0c6781ce42df41516e12f146be3d4 (patch)
tree112c9fd7eb7eac7a8f5850562212041862849deb
parent5ef1021d88a0741845565390393f8e09309d638a (diff)
downloadmruby-ebb337b132a0c6781ce42df41516e12f146be3d4.tar.gz
mruby-ebb337b132a0c6781ce42df41516e12f146be3d4.zip
fix multiple value support of max_by; ref #1912
-rw-r--r--mrbgems/mruby-enum-ext/mrblib/enum.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/mrbgems/mruby-enum-ext/mrblib/enum.rb b/mrbgems/mruby-enum-ext/mrblib/enum.rb
index 8ce02177b..586479a21 100644
--- a/mrbgems/mruby-enum-ext/mrblib/enum.rb
+++ b/mrbgems/mruby-enum-ext/mrblib/enum.rb
@@ -278,7 +278,7 @@ module Enumerable
#
# If no block is given, an enumerator is returned instead.
#
- # %w[albatross dog horse].max_by { |x| x.length } #=> "albatross"
+ # %w[albatross dog horse].max_by {|x| x.length } #=> "albatross"
def max_by(&block)
return to_enum :max_by unless block_given?
@@ -290,16 +290,15 @@ module Enumerable
self.each do |*val|
if first
max = val.__svalue
- max_cmp = block.call(val.__svalue)
+ max_cmp = block.call(*val)
first = false
else
- if cmp = block.call(val.__svalue) > max_cmp
+ if cmp = block.call(*val) > max_cmp
max = val.__svalue
max_cmp = cmp
end
end
end
-
max
end
end