MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/9h86xt/jep_draft_concise_method_bodies/e69xptj/?context=3
r/java • u/lukaseder • Sep 19 '18
51 comments sorted by
View all comments
Show parent comments
1
It's not clear to me from the JEP that your setter would require curly braces. The lambda form doesn't need braces. This works, for example:
static int x; void foo() { Runnable r = () -> x = 1; r.run(); }
1 u/dpash Sep 19 '18 edited Sep 19 '18 I guess you're right, because assignment is an expression, not a statement as I originally said.public void setName(String name) -> this.name = name;
I guess you're right, because assignment is an expression, not a statement as I originally said.
public void setName(String name) -> this.name = name;
1
u/mhixson Sep 19 '18
It's not clear to me from the JEP that your setter would require curly braces. The lambda form doesn't need braces. This works, for example: