> -----Original Message----- > From: Arnaud Bergeron [mailto:abergeron / gmail.com] > Sent: Monday, January 08, 2007 12:49 PM > To: ruby-core / ruby-lang.org > Subject: Re: String#upto edge case - empty string causes infinite loop <snip> > Since "\377".succ yields "\001\000" I belive it would make > more sense having "".succ return "\000" and continue on from there. Hm, it does seem to be a tradition among other languages: # Perl my $str = ""; print ++$str; # 1 /* C */ #include <stdio.h> int main(){ char* empty = ""; printf("Value: %i\n", atoi(empty) + 1); /* 1 */ return 0; } /* Java */ public class EmptyTest{ public static void main(String[] args){ String empty = ""; System.out.println(empty + 1); /* 1 */ } } > 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. As you suggest, I'm not sure what repurcussions changing the return value of "".succ might have. My approach at least has the advantage of being safe in that regard. However, I can live with either approach. It is just an edge case after all. :) Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.