Ged
Ged

Reputation: 18053

Product with Serializable - reason for

The following:

import scala.collection.mutable.ListBuffer
val saveLineValues1 = ListBuffer(("Apple", "Banana"), ("Orange", "Pineapple", "Kiwifruit"))

shows:

saveLineValues1: scala.collection.mutable.ListBuffer[Product with Serializable] = ListBuffer((Apple,Banana), (Orange,Pineapple,Kiwifruit))

What impact does it have on processing? Cannot see any reasonable explanation for this. I understand the SO 37477709 thread, but not so here. Beacuse I did not state a class? I think a lot of people are using SCALA without understanding some aspects, like this.

Upvotes: 0

Views: 1536

Answers (1)

Nagarjuna Pamu
Nagarjuna Pamu

Reputation: 14825

Type of first element in your list buffer is scala.Tuple2 which is a subtype of Product with Serializable

Type of second element in your list buffer is scala.Tuple3 which is a subtype of Product with Serializable

The final result is ListBuffer of Product with Serializable which is the common super type of Tuple2 and Tuple3

All case classes and tuples are sub type of Product with serializable

Upvotes: 1

Related Questions