Member variables in method are null when called as delegate from thread
Paul Backus
snarwin at gmail.com
Mon Jan 11 23:52:55 UTC 2021
On Monday, 11 January 2021 at 16:10:49 UTC, Steven Schveighoffer
wrote:
> There are some... odd rules.
>
> struct S
> {
[...]
> immutable int e = 5; // stored in data segment, not per
> instance!
Are you sure?
struct S
{
immutable int n = 123;
this(int n) { this.n = n; }
}
void main()
{
S s1;
S s2 = 456;
assert(s1.n == 123);
assert(s2.n == 456);
}
More information about the Digitalmars-d-learn
mailing list