How to assign and compare arrays to SumType?

confuzzled con at fuzzled.com
Tue Jun 11 17:38:01 UTC 2024


On Tuesday, 11 June 2024 at 16:41:46 UTC, confuzzled wrote:
>
> Also, assuming that {1} read "SumType!(double)[] data;", what 
> would be the proper way to accomplish the assignment at {2} and 
> the subsequent comparison.
>

Not sure how to do solve the fist part of the question yet but I 
was able to get this part done.

     s.data = [SumType!double(1.7), SumType!double(2.7), 
SumType!double(3.7), SumType!double(4.7), SumType!double(5.7)];
     assert(s.data == [SumType!double(1.7), SumType!double(2.7), 
SumType!double(3.7), SumType!double(4.7), SumType!double(5.7)]);

Wander if there is a more succinct way to do this?

>
> P.S. Is news.digitalmars.com still operational? I'm unable to 
> access it through Thunderbird.




More information about the Digitalmars-d-learn mailing list