Skip to content

Instantly share code, notes, and snippets.

@felipehummel
Last active December 16, 2015 15:09
Show Gist options
  • Save felipehummel/5453999 to your computer and use it in GitHub Desktop.
Save felipehummel/5453999 to your computer and use it in GitHub Desktop.
scala> trait MyTrait extends (String => Int => Int)
defined trait MyTrait
scala> class X extends MyTrait {
| def apply(x: String)(i: Int): Int = 10
| }
<console>:8: error: class X needs to be abstract, since method apply in trait Function1 of type (v1: String)Int => Int is not defined
(Note that T1 does not match String)
class X extends MyTrait {
scala> class X extends MyTrait {
| def apply(x: String): Int => Int = (x: Int) => 10
| }
defined class X
@felipehummel
Copy link
Author

This works:
scala> class X extends MyTrait {
| def apply(x: String): Int => Int = (x: Int) => 10
| }
defined class X

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment