https://kotlinlang.org logo
Title
g

gildor

03/06/2018, 8:19 AM
But I see another case where assignment inside of expression would be helpful. It’s
when
expression with assignment: https://youtrack.jetbrains.com/issue/KT-4895 There is a big dissussion and looks like assignment inside
when
is the best proposal imho. Probably, if Kotlin team decide to implement this for
when
it would make sense to do also for
if
m

miszmaniac

03/06/2018, 8:21 AM
I would use that many times already if it’d exist:)
g

gildor

03/06/2018, 8:22 AM
Yes, exactly. Case with
when
looks like much more common and important than
guard
for
if
m

miszmaniac

03/06/2018, 8:22 AM
Especialy when using
fun test () = when () {}
syntax:)
g

gildor

03/06/2018, 8:33 AM
But for when again, I see why this is not really high priority feature. Because you can just create local variable before when
m

miszmaniac

03/06/2018, 8:35 AM
I know, it’s just a syntax sugar in this case, that you don’t have use block body
g

gildor

03/06/2018, 8:41 AM
yeah