Is it true than in Kotlin a function cannot return...
# getting-started
d
Is it true than in Kotlin a function cannot return multiple values?!?!?
n
multiple values means you aren't really using the type system nicely. in a pinch you can use Pair or Triple, but usually you want a data class. all are easy to destructure.
d
in Go and Swift, you can return multiple values, and it’s really useful
r
Actually not quite. In Go and Swift (as well as many other languages like TypeScript, Rust, Python, etc.), you can return a tuple, which is kind of like an anonymous container that holds arbitrary other values. You're still only returning a single value, but they add some nice syntax sugar that makes it easy and smooth. Kotlin does not support tuples, so your best bet is to do as @nanodeath suggested.
👆 3