From: 7stud -- Date: 2009-05-10T15:10:34+09:00 Subject: Re: ruby string slice/[] w/ range, weird end behavior Robert Klemme wrote: > On 09.05.2009 02:19, Gary Yngve wrote: >> On May 8, 4:47 pm, Eleanor McHugh >> wrote: >>> "foo"[3..3] => "" >> .. >>> index [3] is actually the end of the string so whilst the range >>> accesses the string after any characters in it, it's still accessing >>> the string in a valid range. >> >> Maybe in the native C. But why should that be exposed? >> And why shouldn't index[3] return "" if you are correct? > > If we change perspective a bit, the behavior seems pretty naturally to > me: if you execute this: It doesn't to me. I'll throw in with the op: that is stupid behavior and whoever wrote the docs had no idea how the end of a string is handled in ruby. Typical crappy ruby documentation. -- Posted via http://www.ruby-forum.com/.