Guest User

Untitled

a guest
Jun 20th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. class NeedsImplicitSuffix(prefix: String)(implicit suffix: String) {
  2. def doImplicitly(): String = {
  3. s"$prefix-$suffix"
  4. }
  5. }
  6.  
  7. class HasPrefixInConstructor(suffix: String) {
  8. def thisWontCompile(): NeedsImplicitSuffix = {
  9. new NeedsImplicitSuffix("that")
  10. }
  11. }
  12.  
  13. error: could not find implicit value for parameter suffix: String
  14.  
  15. class HasPrefixInConstructor(suffix: String) {
  16. def thisWontCompile(): NeedsImplicitSuffix = {
  17. new NeedsImplicitSuffix("that")(suffix) // suffix is passed explicitly
  18. }
  19. }
Add Comment
Please, Sign In to add comment