Why does Nullable implicitly casts when assigning a variable but not when returning from a function?

Andy Valencia dont at spam.me
Wed Apr 10 21:38:22 UTC 2024


On Wednesday, 10 April 2024 at 20:41:56 UTC, Lettever wrote:
> ```
> import std;
>
> Nullable!int func() => 3;
> void main() {
>     Nullable!int a = 3;
>     //works fine
>     Nullable!int b = func();
>     //does not compile
> }

Why make func() Nullable?  It just wants to give you an int, 
right?  Making it a function returning an int fixes this.

Andy



More information about the Digitalmars-d-learn mailing list