Reputation: 879
Is there a way to declare a fully-applied function without a full new lambda?
scala> val F = (x: Int) => math.pow(x,2)
F: Int => Double = <function1>
scala> val G = F(3)
G: Double = 9.0
How can I declare it such that G is an:
() => Double = <function0>
Without doing this:
scala> val G = () => F(3)
G: () => Double = <function0>
? The _ notation doesn't seem to do the trick:
scala> val G = F(3) _
<console>:8: error: _ must follow method; cannot follow Double
val G = F(3) _
Upvotes: 0
Views: 286
Reputation: 22105
There is no way. The shortest form is what you came up with, i.e., () => F(3)
.
Upvotes: 1