Luke Sleeman
01/20/2020, 4:55 AM// 1
something?.let { return it }
Or
// 2
if(something != null) { return something }
Mikael Alfredsson
01/20/2020, 7:06 AMsomething
is mutable and accessible from other threads, 2
might still return nullarekolek
01/20/2020, 8:13 AMMikael Alfredsson
01/20/2020, 8:16 AMSmart cast to 'Int' is impossible, because 'something' is a mutable property that could have been changed by this time
(assuming something
is an Int?) (so the compiler actually stops you from making this mistake)Eduardo Pinto
01/21/2020, 7:29 AMCzar
01/28/2020, 5:29 PMif (something == null) calculateAlternative() else something
Or even return something ?: calculateAlternative()
Eduardo Pinto
01/30/2020, 9:43 AMgildor
05/04/2020, 9:45 AMif (something != null) return something