https://kotlinlang.org logo
#announcements
Title
# announcements
a

Ashutosh Panda

12/08/2019, 1:47 PM
This is the error
k

karelpeeters

12/08/2019, 1:47 PM
Please send you entire message at once, this is annoying as we get multiple notifications and we don't know where to start a thread.
2
But
Pair
is for two values, you probably want
Triple
instead.
a

Ashutosh Panda

12/08/2019, 1:48 PM
Oh sorry
Is there something after triole
sorry triple
k

karelpeeters

12/08/2019, 1:49 PM
(you can edit messages too to fix typos 😉 )
1
a

Ashutosh Panda

12/08/2019, 1:49 PM
Ok but code is showing error
error: type inference failed. Expected type mismatch: inferred type is Pair<Pair<String, String>, Int> but Triple<String, String, Int> was expected
return ("Hi" to "Bye" to 5)
k

karelpeeters

12/08/2019, 1:50 PM
And no, the standard library doesn't have anything for 4 values or higher, but data classes are pretty easy:
data class MyReturn(val x: String, val y: String, val z: Int, val w: Int)
Descructuring declarations work just the same way as they do on tuples. There's also the advantage that you can name the values now.
You can't use multiple `to`s, that creates a nested pair. Use the constructor
Triple("Hi", "Bye", 5)
instead.
a

Ashutosh Panda

12/08/2019, 1:51 PM
Hey Please see the error
k

karelpeeters

12/08/2019, 1:52 PM
Yes I did see it, you're trying to use
to
but that's only for pairs.
a

Ashutosh Panda

12/08/2019, 1:52 PM
what is for triples
k

karelpeeters

12/08/2019, 1:53 PM
Look at my second-last comment, now third.
a

Ashutosh Panda

12/08/2019, 1:53 PM
Thanks