From: "Martin Dürst" Date: 2012-02-15T12:20:46+09:00 Subject: [ruby-core:42650] [ruby-trunk - Feature #5607][Open] Inconsistent reaction in Range of String Issue #5607 has been updated by Martin D��rst. Status changed from Feedback to Open Yukihiro Matsumoto wrote: > Ruby classes often play several roles, for example, Array can be array, stack or queue, according to usage of methods. Range is similar. A range is a class with starti point and end point (and flag for end-exclusion). You can use it as interval or sequence of iterated objects from start to end. > > In most cases (especially for numbers) those two behave same, but for strings, they behave quite differently, you have to care about how to use ranges. The following methods treat ranges as intervals: > > min, max, cover? > > The other methods like the following treat ranges as seqeunces: > > ===, each, step, member?, include?, and methods inherited from Enumerable This makes a lot of sense so far. But the example uses #to_a, which *is* inherited from Enumerable. And still it treats a range as an interval, not as a sequence. I have reopened this. I think it should be a bug, not a feature. I would have changed this to a bug if I knew how. Or should we reopen #2323? ---------------------------------------- Feature #5607: Inconsistent reaction in Range of String https://bugs.ruby-lang.org/issues/5607 Author: Yen-Nan Lin Status: Open Priority: Normal Assignee: Category: Target version: =begin When I tried to access excel file, I found some inconsistent behavior about range of string. ruby-1.9.3-p0 :001 > ("A".."AB").to_a => ["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"] This behavior is as what I thought. ruby-1.9.3-p0 :002 > ("X".."AB").to_a => [] However, I tried to access "X" to "AB", and its reaction is inconsistent with above example. I hope that behavior would be consistent in future release. Thanks! =end -- http://bugs.ruby-lang.org/