In expression for array

Robert Fraser fraserofthenight at gmail.com
Wed Jan 23 21:21:18 PST 2008


kede wrote:
> Hi All,
> 
> How about adding In expressions for general arrays in addition to assoc arrays:
> 
>  if ('i' in eyes)
>  ...
> 
> as a simple replacement for the more verbose
>  foreach(c; eyes)
>    if (c == 'i')
>      ...
> 
> I think its a common enough pattern to warrant inclusion?
> 
> Have fun,
> kede

Not as it is presented there; I may have used that pattern twice in my 
whole programming career (If order doesn't matter, a hashtable is a 
better option).

If the operator returned the index (a la the standard library function 
find() ), it would be much more useful. But I'm fine with it being a 
function.



More information about the Digitalmars-d mailing list