Advertisement
Guest User

Untitled

a guest
Dec 21st, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. class Foo {
  2. trait TypeClass[X]
  3. object TypeClass {
  4. implicit val gimme = new TypeClass[Int]{}
  5. }
  6.  
  7. def foo[X : TypeClass](p: X): Unit = println("yeah " + p)
  8. }
  9.  
  10. // compiles
  11. val foo = new Foo()
  12. foo.foo(4)
  13.  
  14. //does not compile
  15. new Foo().foo(4)
  16.  
  17. could not find implicit value for evidence parameter of type _1.TypeClass[Int]
  18. [error] new Foo().foo(4)
  19. [error]
  20.  
  21. val foo = new Foo() // does have a value type foo.type
  22. new Foo() // doesn't have a value type
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement