Hi folks,
What the heck is going on here? Why does this expect a string?
scala> def double[A: Numeric](a: A) = a + a
<console>:7: error: type mismatch;
found : A
required: String
def double[A: Numeric](a: A) = a + a
^
Thanks,
Lyle
Thanks, Rob!
Yeah, I don’t see the use in Predef.any2stringadd when you have string interpolation, and the format method on Strings.
I’m surprised that Numeric would be included by default, but not the implicits. But then again, I guess it’s safer not to include the implicits.
If only that safety rule were followed with any2stringadd.
So much simpler in Haskell:
Prelude> let double n = n + n
Prelude> double 1
2
Prelude> double 1.2
2.4