From: naruse@... Date: 2018-05-17T05:21:54+00:00 Subject: [ruby-core:87098] [Ruby trunk Bug#14699] Subtle behaviors with endless range Issue #14699 has been updated by naruse (Yui NARUSE). Target version set to 2.6 Need to be discussed with mrkn before December. ---------------------------------------- Bug #14699: Subtle behaviors with endless range https://bugs.ruby-lang.org/issues/14699#change-72066 * Author: mame (Yusuke Endoh) * Status: Open * Priority: Normal * Assignee: * Target version: 2.6 * ruby -v: * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- Currently, some Range's methods behaves weirdly with endless range. ## Range#max Range#max always returns nil. Is this okay, or is another result expected? ``` p (0..).max #=> nil p (0..).max(3) #=> nil p (0..).max {|a, b| a <=> b } #=> nil ``` Note that `(0..).min {|a, b| a <=> b }` gets stuck. I think Range#min and Range#max should behave the same if a block are passed, but I'm uncertain what behavior is preferable. ## Range#last Range#last returns nil if no argument is passed. But it gets stuck if a length argument is passed. Is this okay? ``` p (0..).last #=> nil p (0..).last(3) #=> stuck ``` ## Range#size Range#size returns nil for endless range. I think this is somewhat reasonable because `("a".."z").size` returns nil. -- https://bugs.ruby-lang.org/ Unsubscribe: