I created this function on Scala REPL
scala> val multiDouble = (input :Double) =>
| {
| val toMulti = 2;
| toMulti * input
| }: Double
And the output is val multiDouble: Double => Double = Lambda$1351/1709493124@7b44bfb8
For what I've studied it should be val multiDouble: Double => Double = <function01>
I don't understand why Scala REPL prints Lambda$1351/1709493124@7b44bfb8
and not <function01>
.
In Scala 2.11- functions are printed as <function01>
, in Scala 2.12+ they are printed as Lambda$.../...@...
2.12 lambdas have different toString
https://github.com/scala/scala-dev/issues/67
@retronym:
It is unavoidable if we use
LambdaMetaFactory
, which doesn't expose a way to provide an implementation oftoString
. (Default methods in interfaces themselves can't override methods in Object, either).We could provide
ScalaLambdaMetafactory
to generate precisely what we want, but the risk is that we will forgo current or future optimizations in HotSpot targetting LMF.
Scala 2.12.0: output of assigning a function literal to a value
datatype of anonymous function vs named function in scala
https://contributors.scala-lang.org/t/functionns-tostring-should-show-the-types/2572