A tuple is a collection of elements in ordered form. If there is no element present, it is called empty tuple. You can use tuple to store any type of data. You can store similar type or mix type data also. You can use it to return multiple values from a function
Scala Tuple Example
In the following example, we have created tuple of different types of elements.
(1,5,8,6,4) (Apple,Banana,Gavava) (2.5,8.4,10.5) (1,2.5,India)
Scala Tuple Example: Accessing Tuple Elements
In this example, we are accessing tuple elements by using index. Here, we are using productIterator for iterating tuple elements.
iterating values: 1 2.5 India Accessing values: 1 2.5
Next TopicScala Tuple Example