[#70843] Re: [ruby-cvs:58952] hsbt:r51801 (trunk): * lib/rubygems: Update to RubyGems HEAD(fe61e4c112). — Eric Wong <normalperson@...>
hsbt@ruby-lang.org wrote:
3 messages
2015/09/17
[ruby-core:70698] [Ruby trunk - Bug #11471] min, min_by, max, max_by with optional parameter return a wrong value
From:
funny.falcon@...
Date:
2015-09-09 06:00:08 UTC
List:
ruby-core #70698
Issue #11471 has been updated by Yura Sokolov.
Algorithm should be based on a heap.
----------------------------------------
Bug #11471: min, min_by, max, max_by with optional parameter return a wrong value
https://bugs.ruby-lang.org/issues/11471#change-54090
* Author: Tsuyoshi Sawada
* Status: Assigned
* Priority: Normal
* Assignee: Akira Tanaka
* ruby -v:
* Backport: 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED
----------------------------------------
This is reported in StackOverflow: http://stackoverflow.com/questions/32121749/why-20-13-14-min2-13-20. Sometimes `min`, `min_by`, `max`, `max_by` with an optional parameter return a wrong value.
[20, 32, 32, 21, 30, 25, 29, 13, 14].min(2) # => [13, 20]
[20, 32, 32, 21, 30, 25, 29, 13, 14].min_by(2, &:itself) # => [13, 20]
[0, 0, 0, 0, 0, 0, 1, 3, 2].max(2) # => [3, 1]
[0, 0, 0, 0, 0, 0, 1, 3, 2].max_by(2, &:itself) # => [3, 1]
---Files--------------------------------
enum_nmin_filter_fix.patch (2.42 KB)
--
https://bugs.ruby-lang.org/