scala-with-cats
scala-with-cats copied to clipboard
Printable Library part 3: Extension method `format` conflicts with `StringLike.format`
implicit val catPrintable: Printable[Cat] =
(cat: Cat) => {
import PrintableInstances._
import PrintableSyntax._
val name = cat.name.format // compiler error on String
val age = cat.age.format // works fine on Int
val color = cat.color.format // compiler error on String
s"$name is a $age year-old $color cat"
}
I suggest to rename format
to fmt
to avoid the conflict.
Ah. That old chestnut. Thanks for the heads up. I’m travelling this week but will take a look next week.
Cheers, Dave On Tue, 28 Nov 2017 at 11:29, Heiko Seeberger [email protected] wrote:
implicit val catPrintable: Printable[Cat] = (cat: Cat) => { import PrintableInstances._ import PrintableSyntax._ val name = cat.name.format // compiler error on String val age = cat.age.format // works fine on Int val color = cat.color.format // compiler error on String s"$name is a $age year-old $color cat" }
I suggest to rename format to fmt to avoid the conflict.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/underscoreio/advanced-scala/issues/99, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOI55wGb9nSzW1JTwvDDM2PaIe48jU_ks5s6-CYgaJpZM4QtAo0 .
This is fixed, a mere 7 years after it was reported! I use display
and print
as the method names.