Advertisement
Guest User

Untitled

a guest
Nov 15th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.47 KB | None | 0 0
  1. scala> def f(implicit x: Int) = println(x)
  2. f: (implicit x: Int)Unit
  3.  
  4. scala> f
  5. <console>:9: error: could not find implicit value for parameter x: Int
  6.               f
  7.               ^
  8.  
  9. scala> implicit val x1 = 3
  10. x1: Int = 3
  11.  
  12. scala> f
  13. 3
  14.  
  15. scala> implicit val x2 = 4
  16. x2: Int = 4
  17.  
  18. scala> f
  19. <console>:11: error: ambiguous implicit values:
  20.  both value x1 of type => Int
  21.  and value x2 of type => Int
  22.  match expected type Int
  23.               f
  24.               ^
  25.  
  26. scala>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement