3

Suppose I have a function which takes two parameter.

Function2<T1,T2,R> function;

I want to fix the second parameter and makes it a Function1<T1,R>.

With Function2.apply(T1 t), I can only fix the first parameter, is there a way to fix the second parameter?

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
haoyu wang
  • 1,241
  • 4
  • 17

2 Answers2

4

There's no utility function built into vavr that does a partial application of the second argument. The available utility functions only do partial application for the first argument.

You can easily do the partial application yourself, but you'll need to do that within your own codebase.

static <T1, T2, R> Function1<T1, R> partialApply2(Function2<T1, T2, R> f, T2 p2) {
    return p1 -> f.apply(p1, p2);
}
Nándor Előd Fekete
  • 6,988
  • 1
  • 22
  • 47
-1

In Java, a method signature is part of the method declaration. It's the combination of the method name and the parameter list.

https://www.thoughtco.com/method-signature-2034235

JonR85
  • 700
  • 4
  • 12