In the below given examples, we will create Pair using the constructor and demonstrate how to get the list equivalent of the Pair using toList() function?
toList() function:
The toList() function returns a list representation of the Pair including its first and second values i.e., it converts this pair into a list.
Syntax:
fun <T> Pair<T, T>.toList(): List<T>
Example 1:
Output:
Example 2:
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer