From: mail@... Date: 2017-06-15T07:24:54+00:00 Subject: [ruby-core:81690] [Ruby trunk Bug#13663] `String#upto` doesn't work as expected Issue #13663 has been reported by sos4nt (Stefan Sch����ler). ---------------------------------------- Bug #13663: `String#upto` doesn't work as expected https://bugs.ruby-lang.org/issues/13663 * Author: sos4nt (Stefan Sch����ler) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin15] * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- Given that `String#upto` uses `String#succ` to generate successive values, I'd expect ```ruby 'x'.upto('ac').to_a #=> [] ``` to return: ```ruby ["x", "y", "z", "aa", "ab", "ac"] ``` Instead, an empty array is returned. This seems to depend on whether the the receiver is greater than the argument or not: ```ruby 'x' <=> 'ac' #=> 1 ``` It works just fine in this case: ```ruby 'b'.upto('ca').to_a #=> ["b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", # "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "aa", # "ab", "ac", "ad", "ae", "af", "ag", "ah", "ai", "aj", "ak", "al", # "am", "an", "ao", "ap", "aq", "ar", "as", "at", "au", "av", "aw", # "ax", "ay", "az", "ba", "bb", "bc", "bd", "be", "bf", "bg", "bh", # "bi", "bj", "bk", "bl", "bm", "bn", "bo", "bp", "bq", "br", "bs", # "bt", "bu", "bv", "bw", "bx", "by", "bz", "ca"] ``` Presumably because of: ```ruby 'b' <=> 'ca' #=> -1 ``` -- https://bugs.ruby-lang.org/ Unsubscribe: