Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Nullable!(Nullable!int) refuse to compile?

Tags:

d

phobos

The following code refuses to compile:

Nullable!(Nullable!int) nni = Nullable!(Nullable!int)(10);

With this error message:

Error: inout method nullable.Nullable!(Nullable!(immutable(int))).Nullable.this is not callable using a mutable object

Why?

like image 423
Meta Avatar asked Apr 29 '26 12:04

Meta


1 Answers

It seems like a bad error message.

The argument to the constructor of Nullable!(T) is T. In this case, T is a Nullable!int, but you're passing in an int. You need to wrap the int in a nullable.

Nullable!(Nullable!int) foo = Nullable!(Nullable!int)(Nullable!int(10));
like image 177
Colonel Thirty Two Avatar answered May 03 '26 04:05

Colonel Thirty Two



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!