https://kotlinlang.org logo
Title
k

kevinmost

02/01/2018, 5:23 PM
that'd be slightly better (but still terrible IMO) as
val (one, two, three) = IntArray(3) { 0 }
a

adam-mcneilly

02/01/2018, 5:29 PM
As I said to the other thread, Your scientists were so preoccupied with whether or not they could, they didn't stop to ask if they should.
k

kevinmost

02/01/2018, 5:30 PM
Agreed, if I had to do this, I'd do:
val one = 0
val two = 0
val three = 0
maybe pull up
0
into a top-level constant
a

adam-mcneilly

02/01/2018, 5:51 PM
Yeah, I would just pull it out. I can see why it's less concise than the java way, but I would argue that this is negligible to a certain amount. If you truly have a large number of variables that are starting out at the same value, then an array may not be the worst idea. It just looks awful for 3 items. But imagine 10, or 20.
k

kevinmost

02/01/2018, 5:53 PM
Yup, totally agree. I don't think I've ever even used the Java construct for assigning to multiple variables simultaneously
would rather just be explicit, honestly. Conciseness is less important than readability IMO
☝️ 1
a

adam-mcneilly

02/01/2018, 6:07 PM
100%. I know some developers who love to write
for (...) if (...) return true
in one line, but I never did. Until I came to Kotlin, but that's only because I have
.any { }
hahaha.