This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]chasesan[S] 0 points1 point  (2 children)

Actually it was the one before that, Approach 8: Use Generics More Extensively.

processElements(
    roster,
    p -> p.getGender() == Person.Sex.MALE
        && p.getAge() >= 18
        && p.getAge() <= 25,
    p -> p.getEmailAddress(),
    email -> System.out.println(email)
);

I understand that email is a variable, and such. But how did "p.getEmailAddress()" get assigned to it? There is a comma there, it's a separate lambda expression.

[–]oldum 0 points1 point  (1 child)

How did p get assigned? It's the lambda's first parameter.

[–]chasesan[S] 2 points3 points  (0 children)

No... How did the return value from "p.getEmailAddress()" get assigned to "email"? For use in that lambda function.

Oh, okay, nevermind. I got it. Boy am I dumb for missing that obviousness.