With Scala 2.10+ String Interpolation can be made. So I have this question. How can you do this:
println(f"$foo(100,51)%1.0f" )
considering foo is a function like:
def foo(x1:Int , x2:Int) : Double = { ... }
From what I understand the way this is evaluated makes foo considered to have no arguments beacause the message I get is :
missing arguments for method foo in object bar;
follow this method with `_' if you want to treat it as a partially applied function
I tried using parenthesis but errors still occur.
Wrap the call to foo
in curly brackets.
For instance let
def foo(x1: Int, x2: Int) : Double = Math.PI * x1 * x2
where for example
foo(100,51)
res: Double = 16022.122533307946
Then
scala> println(f"${foo(100,51)}%1.0f" )
16022
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With