Reputation: 31
Happy new year everyone!
I have the following exercise for my Programming courses:
Write a class named Imbauba. Class must contain the following method:
A public method named dit which has a parameter (Function Float, Float type) named dawnward and returns Fuction Float, Float result. Lambda function which is returned must contain the value of dawnward divided by 67
public class Imbauba {
public Function<Float, Float> dit(Function<Float, Float> dawnward) {
Function<Float, Float> sss = (a) -> dawnward / 67F;
return sss;
}
}
This is what I've done so far. I have no clue how to continue. Can anyone guide me close to the solution? Thanks in advance
Upvotes: 1
Views: 103
Reputation: 147124
You need to call the method on the Function
. There is no funky syntaz to call the "function" of a functional interface. Something like:
Function<Float, Float> sss = (a) -> dawnward.apply(a) / 67F;
@VLAZ mentions andThen
in the comments. compose
does the same thing in the opposite order. I think they are detrimental to readability, and are only really useful if it avoids creating another lambda expression (and even then I'd prefer not to bother).
Upvotes: 1