What is the point of List.component1 -> 5 funct...
# getting-started
t
What is the point of List.component1 -> 5 functions?
j
These functions are automatically called in destructuring declarations. This allows you to write:
Copy code
val (first, second, third) = myList
Behind the scenes, this will call
myList.component1()
(and 2 and 3) and assign the result to each of these variables. You will also find such functions automatically generated for data classes. You can also declare such functions yourself in your own classes if you want.
t
Thanks so much. Why does it stop at 5 though?
because more than 5 destructuring declarations in a statement is code smell?
j
Well, I don't know for sure, but that would be my guess, yes
t
oh ok gotcha. Thanks!