Created
August 19, 2013 16:09
-
-
Save tpolecat/6270850 to your computer and use it in GitHub Desktop.
view bound example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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