In Dart, checking for a value to be == null
seems similar to checking if it is Null
. Why is the former more preferable?
It is the type of comparison you are doing. In == null
, you are comparing an object/primative to null
whereas in the latter, is Null
, null
is an object. It makes no difference in the compiler.
== null
is more favourable as the two being compared could be both primitives, which saves memory in the system.
== null
is familiar to developers coming from other popular languages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With