Reputation: 2576
In Scala a method signature with 2 arguments, one of which is a function can be written in the following ways:
def methodFoo(funcBar: (Int => Boolean))(baz: List[Int])
Or:
def methodFoo(funcBar: (Int => Boolean), baz: List[Int])
Depending on the signature the method's calls have to be modified accordingly. But is that the only difference between these two signatures or do these syntax cause differences in execution?
Upvotes: 2
Views: 248
Reputation: 12998
As for the execution, there is no difference. They translate into the same byte code:
class A {
def f1(a: Int, b: Int) = a + b
def f2(a: Int)(b: Int) = a + b
}
results in
public int f1(int, int);
public int f2(int, int);
if you look at the .class file using javap
. This is required for compatibility with Java.
Multiple argument give you other syntactical features, see here:
Upvotes: 1