I was coding in Scala and I came across this issue. The following code compiles just fine:
val speed: (Int, Int) => Float = _.toFloat / _
and by the same logic I thought this would too, but it does not
val printSpace: String => Unit = print(_ + " ")
Could anyone explain me why?
I tried to change it to
val printSpace: String => Unit = s => print(s +" ")
which works but I do not understand why the first version does not since it specifies that _
is a string