dotgnu-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ReturnValueDescription (was Re: [DotGNU]String.LastIndexOf(String s) bra


From: Stephen Compall
Subject: ReturnValueDescription (was Re: [DotGNU]String.LastIndexOf(String s) brain damage...)
Date: Mon, 11 Nov 2002 12:36:16 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2b) Gecko/20021028

Jonathan P Springer wrote:
I've spent today banging my head against the ECMA specs for
String.LastIndexOf and while I don't agree with them, I'm beginning to
understand them.

Unfortunately, I can't tell whether I'm coming or going at this point,
so I need a second opinion...

static void Main() {

        String s = "foobar";
        int x = s.LastIndexOf("foo");
        int y = s.LastIndexOf("oba");

        System.Console.WriteLine(x + "," + y);
}

What's the output?  "0,2" or "2,4"?  My preference would be the former,
but the specs are ambiguous and confused enough that I could be easily
convinced that #2 is what should be produced.

value was found. ReturnValueDescription: A positive number equal to the index of the start of the last substring in the current instance that is equal to value

So it appears that you are correct: 0,2

Though the bit about returning 0 when value=="" doesn't make sense, but that's a different story.

--
Stephen Compall
Also known as S11001001
DotGNU `Contributor' -- http://dotgnu.org

The main clarity, for me, was the sense that if you want to have a
decent life, you don't want to have bits of it closed off. This whole
idea of having the freedom to go in and to fix something and modify
it, whatever it may be, it really makes a difference. It makes one
think happily that after you've lived a few years that what you've
done is worthwhile. Because otherwise it just gets taken away and
thrown out or abandoned or, at the very least, you no longer have any
relation to it. It's like losing a bit of your life.
        -- Robert Chassell



reply via email to

[Prev in Thread] Current Thread [Next in Thread]