From: dblack@... Date: 2007-07-07T21:04:28+09:00 Subject: Re: Array#values_at bug? Hi -- On Sat, 7 Jul 2007, John Lam (CLR) wrote: > There's also similar behavior in other range-like entities in strings: > > "foo"[3,0] == "" > > But > > "foo"[4,0] == nil > > Do folks depend on this kind of behavior? I'll need to add a special > case to my string implementation to replicate this behavior in > IronRuby. Or should I do the correct thing and make "foo"[3,0] == > nil? The slippery slope :-) I admit I'm a compatability fan, even for corner cases (though not for bugs, so obviously if Matz rules it a bug that's a different matter). Meanwhile, I'm wondering whether the behavior is based on the idea that "foo"[3] is a position to the right of the second 'o' but to the left of the end-of-string (in the regex manner), so that you're still looking at the string (not nil) but at a point where there are zero characters left. So asking for 0 characters from that point gives you a string rather than nil, just as "foo"[1,0] would. I don't know whether that was how it was designed but I think it might be. David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com)