Skip to content

Instantly share code, notes, and snippets.

@tpolecat
Created August 19, 2013 16:09
Show Gist options
  • Save tpolecat/6270850 to your computer and use it in GitHub Desktop.
Save tpolecat/6270850 to your computer and use it in GitHub Desktop.
view bound example
case class Box[A](a:A) {
def len1(implicit ev: A <:< Seq[_]) = a.length
def len2(implicit ev: A => Seq[_]) = a.length
}
Box(List(1,2,3)).len1 // ok
Box(List(1,2,3)).len2 // ok
Box("foo").len1 // doesn't compile
Box("foo").len2 // ok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment