Skip to content

Instantly share code, notes, and snippets.

@pnf
Created June 23, 2013 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pnf/5843375 to your computer and use it in GitHub Desktop.
Save pnf/5843375 to your computer and use it in GitHub Desktop.
Shows errors encountered trying the examples at http://twitter.github.io/scala_school/advanced-types.html
Welcome to Scala version 2.10.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_21).
Type in expressions to have them evaluated.
Type :help for more information.
scala> implicit def strToInt(x:String) = x.toInt
warning: there were 1 feature warning(s); re-run with -feature for details
strToInt: (x: String)Int
scala> class C[A](v:A){def a(implicit ev:A=>Int)=123+ev(v)}
defined class C
scala> class D[A](v:A){def a[A<%Int]=123+v}
<console>:8: error: overloaded method value + with alternatives:
(x: Double)Double <and>
(x: Float)Float <and>
(x: Long)Long <and>
(x: Int)Int <and>
(x: Char)Int <and>
(x: Short)Int <and>
(x: Byte)Int <and>
(x: String)String
cannot be applied to (A)
class D[A](v:A){def a[A<%Int]=123+v}
^
scala> class E[A](v:A){def a(implicit ev:A<%<Int)=123+v}
<console>:8: error: not found: type <%<
class E[A](v:A){def a(implicit ev:A<%<Int)=123+v}
^
<console>:8: error: overloaded method value + with alternatives:
(x: Double)Double <and>
(x: Float)Float <and>
(x: Long)Long <and>
(x: Int)Int <and>
(x: Char)Int <and>
(x: Short)Int <and>
(x: Byte)Int <and>
(x: String)String
cannot be applied to (A)
class E[A](v:A){def a(implicit ev:A<%<Int)=123+v}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment