Skip to content

Instantly share code, notes, and snippets.

@earldouglas
Created July 30, 2013 22:32
Show Gist options
  • Save earldouglas/6117664 to your computer and use it in GitHub Desktop.
Save earldouglas/6117664 to your computer and use it in GitHub Desktop.
scala> List("a", "b", "c").has(42)
<console>:10: error: type mismatch;
found : Int(42)
required: String
List("a", "b", "c").has(42)
^
scala> List("a", "b", "c").has("b")
res1: Boolean = true
trait Container[A] {
def has(a: A): Boolean
}
implicit def listContainer[A](xs: List[A]): Container[A] =
new Container[A] {
override def has(a: A): Boolean = xs.contains(a)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment