diff options
| author | Jun Hiroe <[email protected]> | 2014-03-22 13:56:41 +0900 |
|---|---|---|
| committer | Jun Hiroe <[email protected]> | 2014-03-22 14:51:47 +0900 |
| commit | 5ef1021d88a0741845565390393f8e09309d638a (patch) | |
| tree | 10187a9d2f8933c49e79d5c8959c3028dd19afe2 /mrbgems/mruby-enum-ext | |
| parent | af7db89aa3630264c64da638c6330160c99d94b8 (diff) | |
| download | mruby-5ef1021d88a0741845565390393f8e09309d638a.tar.gz mruby-5ef1021d88a0741845565390393f8e09309d638a.zip | |
Support mulitple values in Enumerable#max_by
Diffstat (limited to 'mrbgems/mruby-enum-ext')
| -rw-r--r-- | mrbgems/mruby-enum-ext/mrblib/enum.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/mrbgems/mruby-enum-ext/mrblib/enum.rb b/mrbgems/mruby-enum-ext/mrblib/enum.rb index e61062e3f..8ce02177b 100644 --- a/mrbgems/mruby-enum-ext/mrblib/enum.rb +++ b/mrbgems/mruby-enum-ext/mrblib/enum.rb @@ -287,14 +287,14 @@ module Enumerable max = nil max_cmp = nil - self.each do |val| + self.each do |*val| if first - max = val - max_cmp = block.call(val) + max = val.__svalue + max_cmp = block.call(val.__svalue) first = false else - if cmp = block.call(val) > max_cmp - max = val + if cmp = block.call(val.__svalue) > max_cmp + max = val.__svalue max_cmp = cmp end end |
