fun whichColor(str: String) = if(str == "blue") Color.Blue else Color.Black
s
Sebastian Aigner
05/26/2021, 6:35 PM
I wanted to introduce some of the syntax sugar gradually, to allow people to acclimate to some of the language parts where Kotlin is different from languages they might already know – a few slides later, I also bring up expression bodies. Your implementation is of course just as valid! 🙂
a
altavir
05/26/2021, 6:36 PM
Yeah, Is see it now.
It is actually a good question if the expression bodies are good, but I just find them irresistable.