Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class NeedsImplicitSuffix(prefix: String)(implicit suffix: String) {
- def doImplicitly(): String = {
- s"$prefix-$suffix"
- }
- }
- class HasPrefixInConstructor(suffix: String) {
- def thisWontCompile(): NeedsImplicitSuffix = {
- new NeedsImplicitSuffix("that")
- }
- }
- error: could not find implicit value for parameter suffix: String
- class HasPrefixInConstructor(suffix: String) {
- def thisWontCompile(): NeedsImplicitSuffix = {
- new NeedsImplicitSuffix("that")(suffix) // suffix is passed explicitly
- }
- }
Add Comment
Please, Sign In to add comment