Hullaballoonatic
08/29/2020, 7:43 PMa, b = b, a
the only place I can think of where commas are not enclosed in ()
is enum
classes. would that case alone cause python swap syntax to turn kotlin into an irregular language or something?
are free-range commas just too dangerous for future expansion? could they not use the same solution as in enum
and require a ;
for only the second time in the language, and thus open up all sorts of destructuring assignment, like that which you see in javascript?Nir
08/29/2020, 7:56 PMNir
08/29/2020, 7:57 PMNir
08/29/2020, 7:57 PMa, b = makeTuple(b, a)
Hullaballoonatic
08/29/2020, 7:57 PMHullaballoonatic
08/29/2020, 7:59 PMval (a, b, c) = elements
because that still existsNir
08/29/2020, 8:03 PMNir
08/29/2020, 8:03 PMNir
08/29/2020, 8:04 PMdata class Tuple1<T>(val first: T)
data class Tuple2<T, U>(val first: T, val second: U)
Nir
08/29/2020, 8:04 PMHullaballoonatic
08/29/2020, 8:04 PMa, b = (c, ...d)
Nir
08/29/2020, 8:05 PMfun<T> makeTuple(first: T) = Tuple1(first)
fun<T, U> makeTuple(first: T, second: U) = Tuple2(first, second)
Nir
08/29/2020, 8:05 PMNir
08/29/2020, 8:06 PMNir
08/29/2020, 8:06 PMHullaballoonatic
08/29/2020, 8:07 PMNir
08/29/2020, 8:08 PMNir
08/29/2020, 8:08 PMNir
08/29/2020, 8:08 PMNir
08/29/2020, 8:08 PMHullaballoonatic
08/29/2020, 8:09 PMval tmp = a
a = b
b = a
Nir
08/29/2020, 8:09 PMNir
08/29/2020, 8:09 PMNir
08/29/2020, 8:10 PMNir
08/29/2020, 8:10 PMHullaballoonatic
08/29/2020, 8:10 PMHullaballoonatic
08/29/2020, 8:11 PMIterable.zip(Iterable)
?Nir
08/29/2020, 8:11 PMNir
08/29/2020, 8:11 PMNir
08/29/2020, 8:11 PMa, b = run { Pair(b, a) }
I thinkNir
08/29/2020, 8:12 PMNir
08/29/2020, 8:12 PMfor a, b, c in zip(x, y, z)
Nir
08/29/2020, 8:12 PMHullaballoonatic
08/29/2020, 8:12 PMNir
08/29/2020, 8:13 PMHullaballoonatic
08/29/2020, 8:13 PMa, b = elements
you can only do
val (a, b) = elements
Nir
08/29/2020, 8:13 PMNir
08/29/2020, 8:13 PMHullaballoonatic
08/29/2020, 8:13 PMHullaballoonatic
08/29/2020, 8:13 PMrun
Nir
08/29/2020, 8:13 PMHullaballoonatic
08/29/2020, 8:30 PM