Tuples deprecated?


#1

I noticed recently that Tuples are deprecated and going to be removed from Kotlin. Why is that? And do you plan to support multiple return values from function in some other way?


#2

Look examples http://kotlin-demo.jetbrains.com/?folder=Multi-declarations&name=Multi-declarations


#3

Have a look at this blog post http://blog.jetbrains.com/kotlin/2012/09/how-do-you-traverse-a-map/


#4

Thank you both for answers.


#5

There's a more compact way to do multiple returns if you use the constructor of a class as the function:

// class constructor contains the logic, no need for a separate function. class only exists to act as a function class foo() {   val returnVal1 = ...   val returnVal2 = ... }

// use it
val f = foo()
println(f.returnVal1)
println(f.returnVal2)


I don’t think there’s a way to use this with multiple assignment, but you have the property names defined in the class so it doesn’t really matter.

Andrey mentioned this approach in a blog post or comment somewhere but I can’t find it.


#6

I just found another blog post that provides some info on this subject:

http://blog.jetbrains.com/kotlin/migrating-tuples/