Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lambda expression for setter

We have lambda expression for getter as below:

Function<Student, String> studentNameGetter = Student::getName;

How about lambda expression for the setter?

like image 921
Kowser Avatar asked Jan 03 '15 21:01

Kowser


1 Answers

I'm not sure what you mean by creating a lambda expression for the setter.

What it looks like you are trying to do is to assign the method reference to a suitable Functional Interface. In that case, the best match is to a BiConsumer:

BiConsumer<Student, String> studentNameSetter = Student::setName;
like image 195
Keppil Avatar answered Oct 22 '22 18:10

Keppil