April 04, 2018
On Sunday, 1 April 2018 at 15:54:16 UTC, Steven Schveighoffer wrote:
> But I'd rather avoid such things if possible. Is there a way around this? Seems rather limiting that I can do:

Is this what you're looking for?

void foo(Nullable!int x = Nullable!int.init)
{   if (!x.isNull) x.get.writeln;
    else writeln;
}

void foo(int x)
{   return Nullable!int(x).foo;
}


void main()
{
   foo(1); // 1
   int x;
   foo(x++); // 0
   foo; // empty line
   foo(x); // 1
   readln();
}
April 04, 2018
On 4/4/18 8:59 AM, Dukc wrote:
> Is this what you're looking for?

See my original post:

> I know I can do things like this:
> 
> void foo(int x) { return foo(nullable(x)); } 

-Steve
April 04, 2018
On Wednesday, 4 April 2018 at 15:44:34 UTC, Steven Schveighoffer wrote:
> See my original post:
>
>> I know I can do things like this:
>> 
>> void foo(int x) { return foo(nullable(x)); }
>
> -Steve

Oops, I read only the body of that function and thought it's a main function constructiong nullable when calling.

Well, short of defining some sort of mixin to do this automatically, no better ideas :(.
1 2 3
Next ›   Last »