5/16/2023 0 Comments Kotlin immutable listVar (a3,b3) = XY(1,2) // destructured assign using data class Var (a2,b2) = Pair(1,2) // alternative destructured assign The good and bad of tuples can be seen in this : Background: The good and bad of the ubiquetous python tuple The python tuple is an immutable list, and the simple ability to use tuples has a special role in the language with any expression with a comma creating a tuple. list comprehension and other iterations vs map, filter, reduce.In kotlin, there are many other options, some inherited from java, and the most common and mostly used for compatibiliy with Java but they all have a logical role: ‘List’ is equivalent to python ‘tuple’, as a tuple is an immutable list. Kotlin provides List and Map as collections, and their mutable forms, MutableList and MutableMap as the main solutions for collections equivalent to Python.įurther, Set and MutableSet are available matching the python ‘set’. Python uses dictionary, list and tuple to hold collections information, with set also available (but not used as quite as often).
0 Comments
Leave a Reply. |