One of the thing I like in D

user1234 user1234 at 12.de
Sat Oct 12 04:07:01 UTC 2024


On Friday, 11 October 2024 at 23:04:20 UTC, Per Nordlöw wrote:
> With next dmd you can use use ref variables aswell as
>
> ```d
> void main() {
>     auto a = 0;
>     auto b = 0;
>     const c = 1;
>
>     ref ptr = (c ? a : b);
>     ptr = 8;
>     assert(a == 8);
>     ptr = (c ? b : a);
>     ptr = 2;
>     assert(b == 2); 			// why does this fail??
> }
> ```
>
> But for some reason the last statement doesn't behave as I 
> believe it should. Is this behavior expected?
>
> For reference see 
> https://dlang.org/changelog/pending.html#dmd.reflocal.

This has to be a bug ;)


More information about the Digitalmars-d mailing list