Search This Blog

Sunday 30 May 2021

Difference between a tuple and collection in scala

 

Difference between Tuple and Collections in Scala :


1. Tuple store heterogenous data, means it can store different data types at a time. Where as collection stores same data type.

2. If we want to return two values from a function, lets say, we would like to return 1 and "Scala" at a time from a function we can use Tuple.

3. At max tuple can store 22 elements, But Collection can store more than 22 elements ( No restriction).



No comments:

Post a Comment