So given the list:
val a:List[Int] = List(1,2,3)
You can do:
a.contains(Option(2))
Which returns false. I understand from the following function definitions that allowing this to compile at all was done on purpose:
def contains[A1 >: A](elem : A1) : scala.Boolean = {...}
sealed abstract class Option[+A]() ...
What I don't understand is why - is there a use case where this is useful? If it automatically flattened the option before the comparison so the above returned true then it might be useful but as is it will always return false.
I ask because it's easy to forget to unwrap your Option variable that you pass to List.contains, leading to potentially difficult to find bugs.
Thanks!