Created
September 4, 2016 16:17
-
-
Save debop/83dabc2132ccebc8a614b049ab5c91cc to your computer and use it in GitHub Desktop.
Tuples in Kotlin ported from Scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Tuple1<out T1 : Any>(override val first: T1) : Product1<T1>, Serializable { | |
override fun toString(): String { | |
return "($first)" | |
} | |
} | |
data class Tuple2<out T1 : Any, out T2 : Any>( | |
override val first: T1, | |
override val second: T2) : Product2<T1, T2>, Serializable { | |
override fun toString(): String { | |
return "($first, $second)" | |
} | |
} | |
data class Tuple3<out T1 : Any, out T2 : Any, out T3 : Any>( | |
override val first: T1, | |
override val second: T2, | |
override val third: T3) : Product3<T1, T2, T3>, Serializable { | |
override fun toString(): String { | |
return "($first, $second, $third)" | |
} | |
} | |
data class Tuple4<out T1 : Any, out T2 : Any, out T3 : Any, out T4 : Any>( | |
override val first: T1, | |
override val second: T2, | |
override val third: T3, | |
override val fourth: T4) : Product4<T1, T2, T3, T4>, Serializable { | |
override fun toString(): String { | |
return "($first, $second, $third, $fourth)" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment