Let's say I have an object Response. Now I would like to check a boolean variable, success, under Response and do an early return is response is not successful.
if(response == null || !response.success){
return;
} //Java version
Now I would like to use Kotlin's null safety check like following
if(response?.success ?: true){
return
}
If I'm not wrong, if either response or success is null we'll return true inside the if condition. However, if response.success is not null and equals to true, we will still return from the function, which is not what I want . How do I correct this condition ?