Having "in" for arrays

Fra Mecca me at francescomecca.eu
Wed Nov 22 08:03:50 UTC 2017


Why doesn't D have a in keyword for arrays?

The docs explains that you can use in only for associative arrays 
but I don't see the reasons for such decision.


Example code:

void main()
{
	auto v = ["r", "i", "o"];
	assert ("r" in v);
}


That currently fails:
main.d(4): Error: incompatible types for (("r") in (v)): 'string' 
and 'string[]'



More information about the Digitalmars-d-learn mailing list