www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - In Expression for Static and DYnamic Arrays

Content-Disposition: inline

Hi, 

Why the `in` expression can only be applied to associative
arrays and cannot be used with static or dynamic arrays as
it is possible with, _e.g._, Python?

The following code is not legal:
----
int[] a = [1,2,3,4,5];
if (1 in a) { }
----
Are there any technical explanation for this limitation? 

Thanks, Rizo.

--
BF6F0265: FB27 BB4C 8F03 4980 C311 0968 E66B 9831 BF6F 0265
Oct 11 2012