Java 8: Where is TriFunction (and kin) in java.util.function? Or what is the alternative?

后端 未结 7 1325
臣服心动
臣服心动 2020-11-30 17:46

I see java.util.function.BiFunction, so I can do this:

BiFunction f = (x, y) -> { return 0; };

What if

7条回答
  •  日久生厌
    2020-11-30 18:20

    Alternative is, add the below dependency,

    
        io.vavr
        vavr
        0.9.0
    
    

    Now, you can use Vavr Function, like below upto 8 arguments,

    3 arguments:

    Function3 f = 
          (a, b, c) -> a + b + c;
    

    5 arguments:

    Function5 f = 
          (a, b, c, d, e) -> a + b + c + d + e;
    

提交回复
热议问题