Project

General

Profile

Actions

Bug #11471

closed

min, min_by, max, max_by with optional parameter return a wrong value

Added by sawa (Tsuyoshi Sawada) over 9 years ago. Updated about 9 years ago.

Status:
Closed
Target version:
-
[ruby-core:<unknown>]

Description

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) enum_nmin_filter_fix.patch helfper (Helder Pereira), 08/21/2015 01:31 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0