- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Seq.indexOf overload
Fri, 2009-02-27, 23:49
Seq.indexOf is overloaded in two method with different functionality.
This causes problems when you put a Seq inside another Seq, for example:
scala> val l = List(1, 2, 3)
l: List[Int] = List(1, 2, 3)
scala> List(l).indexOf(l)
res4: Int = -1
Apparently the "indexOf[B >: A](that : Seq[B])" method is chosen by the
compiler. I saw that the same overload is present in scalax. I don't
know if there are other methods in the collections library that are
overloaded in the same way.
The obvious solution is to rename "indexOf[B >: A](that : Seq[B])" to
indexOfSeq, indexOfSlice or similar.
/Jesper Nordenberg