There’s an example in “Scala in Depth” where the author is explaining how scala can do some level of inference on the arguments passed into the methods. As an example the following is shown:
def myMethod(functionLiteral: A => B):Unit
myMethod({ arg:A => new B})
myMethod({ arg => new B})
Just to figure out what the author is talking about, I do the following in the REPL:
def myMethod(functionLiteral: Boolean => Boolean):Unit = {}
myMethod({a:Boolean => true})
myMethod({a => true})
The only revelatory thing that happens here is that the compiler doesn’t throw an error.
Is the author trying to say that the function argument a is inferred to be a Boolean by the compiler?
Yes the author is saying that dont need to specify that
ais aBooleaninmyMethod({a => true})because the type isBoolean => Boolean== Original answer which makes the first bit compile but misses the point a bit ==
It needed to Be typed with
[A,B].I modified it to return the function so you can see the types in the repl.