In expression for array

Bill Baxter dnewsgroup at billbaxter.com
Thu Jan 24 15:40:05 PST 2008


janderson wrote:
> 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
> 
> 
> I think something like:
> 
> if (contains(eyes, 'i'))
> 
> and
> 
> auto value = find(eyes, 'i');
> 
> should be in the standard library.  It seems excessive to put 'in' in 
> the language.

But 'in' is already in the language.  Are you suggesting it should be 
removed?

--bb



More information about the Digitalmars-d mailing list