Why dtor are not executed when removing a struct from associative arrays?

Learner learner at nowhere.com
Mon Sep 20 12:23:00 UTC 2021


I was expecting something like going out of scope for that

```(D)
import std.stdio;

struct S
{
     ~this()
     {
         writeln("S is being destructed");
     }
}

void main()
{
	S[int] aa;
     aa[1] = S();
     aa.remove(1);
     writeln("Why no dtor call on remove?");
}

I was expecting S instance dtor called
S is being destructed
```



More information about the Digitalmars-d-learn mailing list