On 1/8/07, Yukihiro Matsumoto <matz / ruby-lang.org> wrote:
> Hi,
>
> In message "Re: String#upto edge case - empty string causes infinite loop"
>     on Tue, 9 Jan 2007 01:55:56 +0900, Daniel Berger <Daniel.Berger / qwest.com> writes:
>
> |I noticed that "".upto("anything") causes an infinite loop, since
> |"".succ returns "".
> |
> |Is this just a case of, "Don't do that", or do we want to handle empty
> |strings specially?  Just thought I'd ask.  If we do want to handle it
> |specially, I propose the following patch:
>
> |This will yield an empty string *once* and then break.
>
> It makes sense.  Thank you.
>
>                                                         matz.
>

Since "\377".succ yields "\001\000" I belive it would make more sense
having "".succ return "\000" and continue on from there.

However there might be a problem because letters are treated
differently.  "z".succ yield "aa" and not "}" and the same is true for
"Z" so this might need more thought, but in my opinion yielding the
empty string once is the last expected behavior.

Arnaud