"Andrej Mitrovic" <[email protected]> wrote in message 
news:[email protected]...
> On 9/2/11, Steven Schveighoffer <[email protected]> wrote:
>> Am I missing something, or is it this simple?
>>
>> void appendMenuButton()
>> {
>>     static size_t menuIndex;
>>     auto frameIndex = menuIndex++;
>>     button.connect!(Signal.MouseClick) = { this.showMenu(frameIndex); };
>> }
>>
>> -Steve
>>
>
> Actually It *is* that simple. Which is odd because I swear I've tried
> it once but it didn't work, and now it works again. Something has to
> be messing with the compiler or my brain!

It won't work when loops are involved.  In that case I usually use:
foreach(i; ...)
(int i){
   something = { delegate that uses i like a constant };
}(i); 


Reply via email to