Home > Mobile >  how to fix the second parameter of a function with vavr?
how to fix the second parameter of a function with vavr?

Time:11-10

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?

CodePudding user response:

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);
}

CodePudding user response:

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

  • Related