https://kotlinlang.org logo
t

tipsy

08/13/2017, 4:25 PM
is doing
Copy code
when (boolean) {
    true -> ...
    false -> ... 
}
considered bad?
e

enleur

08/13/2017, 4:26 PM
why not
if(boolean) … else …
t

tipsy

08/13/2017, 4:27 PM
well, that's what i've been doing most my life, but this looks very neat and explicit
m

menegatti

08/13/2017, 4:36 PM
I think
when
is better suited for multiple (>2) branches
otherwise,
if
is more familiar
h

horse_badorties

08/13/2017, 5:13 PM
"Prefer using if for binary conditions instead of when." https://github.com/yole/kotlin-style-guide/issues/11
t

tipsy

08/13/2017, 5:29 PM
@horse_badorties thanks, good read
4 Views