[ruby-talk:02579] Re: String.succ

From: schneik@...
Date: 2000-04-26 07:43:49 UTC
List: ruby-talk #2579

Hi,

Matz writes:
#     on 00/04/26, Dave Thomas <Dave@thomases.com> writes:
#
# |Should
# |
# |   "\377".succ  # -> "\000"
# |
# |I _think_ I'd expect "\001\000".
# |
# |Similarly, "".succ returns "\377", because it uses a carry that was
# |never set.
# |
# |In reality, these are pathological, so I wouldn't call them
# |bugs. However, I'm wondering how to document them.
#
# Ok, I define as following:
#
#   "".succ == ""
#   "\377".succ == "\001\000"

Maybe I missed something, but for simplicity, consistency,
least surprise, ease of remembering, why not:

    "".succ == "\000"

Conrad Schneiker
(This note is unofficial and subject to improvement without notice.)


In This Thread

Prev Next