Return values from auto function

Jesse Phillips Jesse.K.Phillips+D at gmail.com
Sat Nov 7 17:55:25 UTC 2020


On Saturday, 7 November 2020 at 15:49:13 UTC, James Blachly wrote:
>
> ```
>     return i > 0 ? cast(Result) Success!int(i) : cast(Result) 
> Failure("Sorry");
> ```
>

I don't know about the SumType but I would expect you could use a 
construction instead of cast.

import std;
alias Result = Algebraic!(int, string) ;
void main()
{
     auto x = true? Result("fish") : Result(6);

}


More information about the Digitalmars-d-learn mailing list