Test for element in array

Lars Ivar Igesund larsivar at igesund.net
Fri Jul 14 09:31:57 PDT 2006


BCS wrote:

> Don Clugston wrote:
>> Andrei Khropov wrote:
>> 
>>> BCS wrote:
>>>
>>>>  if({foreach(i;a) if(i==j) return true; return false;}())
>>>
>>>
>>> Yeah, this new delegate syntax is cool !
>> 
>> 
>> Wow! I didn't know you could have a naked {} like that as a void
>> delegate. That is cool. Looks as though D has sucked all the juice out
>> of C++, and is moving onto the scripting languages...
>> 
> 
> Not quite naked, without the ending () the type is "bool delegate(void)"
> a.k.a. always true.

The () is for calling it, {} is fine if you want pass (what I would call
naked) a delegate to a function taking delegates as arguments.
 
-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource & #D: larsivi



More information about the Digitalmars-d-learn mailing list