0

Doing somethig else and returning if null in one expression

Is there anyway to reduce this line of code anymore because I don't appreciate the "smart cast" hint. return foo().let { if(it == null) { //Do something else otherValue } else it }

13th Jul 2019, 9:27 PM
Chriptus13
Chriptus13 - avatar
2 Respuestas
0
not that I'm aware, you could use a switch if that exists in kotlin but I don't think it would be better. Don't take my word I'm just answering because no one did. I hope you figured it out by now, its been 1 year...
8th Jun 2020, 11:46 PM
Thomas Bouasli
Thomas Bouasli - avatar
0
thomas bouasli the switch would give the same warning
8th Jun 2020, 11:53 PM
Chriptus13
Chriptus13 - avatar