When I define this function, I can call it without a problem:
scala> val c = (_: String) + "sd"
c: String => String = <function1>
scala> c("1")
res13: String = 1sd
However if I let the above function print the result without returning it, I have the following error:
scala> val b = print((_: String) + "sd")
<function1>b: Unit = ()
scala> b("1")
<console>:26: error: Unit does not take parameters
b("1")
^
I know the system method print returns Unit type, but shouldn't the function b be a function that can be called with an argument as I defined? Why the above b function can not be called with b("1")?
How to understand and solve the problem? Thank you.