Hello Nick,

"Pelle Månsson" <pelle.mans...@gmail.com> wrote in message
news:hjmmod$1io...@digitalmars.com...

I think in should work for keys in an associative array and for
values in a regular array.

This is how it works in python.

Aside from that being how Python does it, why do you see that as
preferable? I see both arrays and associative arrays as things that
map an input value to an output value. The only significant
differences are the implementation details, and the fact that regular
arrays are more restrictive in their sets of valid inputs (must be
integers, must start with 0, and must all be consecutive values). So
having a single syntax work on the outputs for regular arrays, but
then on the inputs for AAs, seems highly inconsistent and error-prone
to me.

I think this is one of the few cases where the strictly logical choice is not the way anyone expect things to work.

That said however, it might make a difference in template code

void fn(T)(T t, T u, int i)
{
if(auto x = i in t) u[i] = *x; }

--

<IXOYE><


Reply via email to