3
Scalaの不変セットがその型で共変ではないのはなぜですか?
編集:この質問を元の回答に基づいて書き直しました scala.collection.immutable.Setクラスは、その型パラメータの共変ではありません。どうしてこれなの? import scala.collection.immutable._ def foo(s: Set[CharSequence]): Unit = { println(s) } def bar(): Unit = { val s: Set[String] = Set("Hello", "World"); foo(s); //DOES NOT COMPILE, regardless of whether type is declared //explicitly in the val s declaration }