Can we fix this?
deadalnix
deadalnix at gmail.com
Thu Sep 30 19:39:21 UTC 2021
On Thursday, 30 September 2021 at 14:44:52 UTC, Steven
Schveighoffer wrote:
> On 9/30/21 10:42 AM, Steven Schveighoffer wrote:
>
>> ```d
>> void delegate() dg;
>> for(int i = 0; i < 100; ++i)
>> {
>> dg = { writeln(i); };
>> }
>>
>> dg();
>> ```
>
> Haha of course, I shouldn't overwrite the same delegate.
>
> It should have been an array of delegates, but the point still
> stands.
>
> -Steve
In that case, you should expect all the delegates to print the
same value. There is one i variable accross all loop iterations.
More information about the Digitalmars-d
mailing list