[Issue 1323] Implement opIn_r for arrays
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jul 9 14:39:49 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1323
------- Comment #8 from wbaxter at gmail.com 2007-07-09 16:39 -------
(In reply to comment #7)
> as to in returning null, that is what 'in' does with AA's; if the key is in the
> AA return a pointer to the value, otherwise, return null.
>
> In fact, the code I wrote works the same as 'in' for AA's
>
> The usual way to use the return from 'in' where it might give null is this:
>
> if(auto v = i in j)
> {
> use(*v);
> }
> else
> {
> // i not in j
> }
Sure, but my point was that it doesn't gain you any efficiency or clarity in
the case of arrays. You might as well do:
if(0<=i && i<j.length)
{
use(j[i]);
}
else
{
// i not in j
}
It's only a few characters longer and clearer in my opinion.
--
More information about the Digitalmars-d-bugs
mailing list