input validation
bearophile
bearophileHUGS at lycos.com
Wed Mar 4 13:30:55 PST 2009
Andrei Alexandrescu:
> Binary search is rather common.
Oh, yes, sorry, I meant among the ones you have listed there...
> As an aside, your use of "index" suggests you return integrals out of
> the function. IMHO that's strongly unrecommended.
I don't want to use too much of your time (that it may be better spent with your new child), but I don't understand what you mean.
That index() function is meant the index position of the item or sub-sequence into the bigger array (or iterable), and it returns -1 if not found. This is an usual design.
Some people think that such controls for -1 value aren't always done, so to avoid that and some bugs, it's better to raise something like IndexException when the needle isn't found.
Bye,
bearophile
More information about the Digitalmars-d
mailing list