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;
if(profitable!=-1)
{
transfer=profitable;
} else
if(blocking off!=-1) {
transfer=blocking off;
} else {
transfer=standard;
}
print(transfer);
}
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
print(transfer);
The IDE complains in regards to the int transfer = … expression.
View Reddit by means of utilitycoder – View Supply