Assist changing to the null-safety means of doing issues

I’ve this code:

void major() {

int profitable=-1;
int blocking off=-1;
int standard=-1;
int transfer=-1;

profitable = 5;
blocking off = 1;
standard = 6;

} else
if(blocking off!=-1) {
transfer=blocking off;
} else {



I attempted to make use of the null-safety means of doing issues however did not paintings… are you able to inform what I am doing incorrect or methods to alter the above to make use of null-safety? This is my try:

int? profitable;
int? blocking off;
int? standard;

blocking off = 1;
standard = 7;

int transfer = profitable ?? blocking off ?? standard; // “standard” won’t ever be evaluated since blocking off cannot be null


The IDE complains in regards to the int transfer = … expression.

View Reddit by means of utilitycoderView Supply

You may also like...

WP2Social Auto Publish Powered By :