> When do you use tuples?
• Tuples are used for fixed size, index safe random access, they are also non-class collections alternative to
Pair
,
Triple
example on chessboard grid which is 8x8 would use
Tuple8
> Tuples VS case class
• For library authors, tuples could be used without importing classes like Pair , Triple, for the case on names tuples they can entirely replace any case or data class example:
•
typealias Point = (x:float, y: float)
• Tuples are also used on
map
,
flatMap
streams to generate next chain data
• Named tuples on scala where also pushed to improve scala-sql mappings as names tuples can be generated on the fly, same can be said for a kotlin/ktor compiler plugin
> How long are tuples?
Longest tuple has been of size 8 for chess/checker board rows/columns