You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by "ocs@ocs.cz" <oc...@ocs.cz> on 2017/02/19 13:37:37 UTC

improve null-handling

Hi there,

is there a way to make sure in Groovy

(a) that instead of "Cannot cast object 'null' with class 'null' to class 'XXX'" for numeric primitive types XXX (like int) one gets simply a XXX containing 0
(b) that instead of "Cannot resolve which method to invoke for [null] due to overlapping prototypes" (which happens e.g., with foo+bar if foo is null) one gets simply null as a result of the expression?

Thanks,
OC


RE: improve null-handling

Posted by "Winnebeck, Jason" <Ja...@windstream.com>.
(a) x ?: 0
(b) foo?.plus(bar)

Jason Winnebeck

-----Original Message-----
From: ocs@ocs.cz [mailto:ocs@ocs.cz] 
Sent: Sunday, February 19, 2017 8:38 AM
To: users@groovy.apache.org
Subject: improve null-handling

Hi there,

is there a way to make sure in Groovy

(a) that instead of "Cannot cast object 'null' with class 'null' to class 'XXX'" for numeric primitive types XXX (like int) one gets simply a XXX containing 0
(b) that instead of "Cannot resolve which method to invoke for [null] due to overlapping prototypes" (which happens e.g., with foo+bar if foo is null) one gets simply null as a result of the expression?

Thanks,
OC

This email message and any attachments are for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message and any attachments.