On Monday, 20 September 2021 at 13:48:01 UTC, Tejas wrote:
On Monday, 20 September 2021 at 12:23:00 UTC, Learner wrote:
[...]

I think it *is* being called:
```d
import std.stdio;

struct S
{
        int a;
        this(int param){
                a = param;
        }
        ~this()
        {
            writeln("S(",a,") is being destructed");
        }
}

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

Output:
S(5) is being destructed
S(10) is being destructed
```
If the destructors were being executed based on the ending of scope, `S(10)` would have been destroyed first.

Oh dear, I made a mistake :(
Sorry, shouldn't have commented out the `writeln`

Reply via email to