Michiel Borkent
Michiel Borkent

Reputation: 34840

Is this an example of type erasure in Scala?

Is this an example of type erasure in Scala?

(None: Option[Int]) == (None: Option[String]) // true

Upvotes: 0

Views: 66

Answers (1)

Pim Verkerk
Pim Verkerk

Reputation: 1066

This is the from the scala source: case object None extends Option[Nothing]

Before erasure both would be None[Nothing] because only a single instance of None exists. Yes this is an example of erasure, but not a realy good one.

Upvotes: 2

Related Questions