New JEP: Concise Method Bodies

Cay Horstmann cay.horstmann at
Thu Sep 20 20:47:13 UTC 2018

Le 19/09/2018 à 23:43, Alex Buckley a écrit :

> Let me focus on the single expression form. The argument we've made is: 
> statement lambdas have a concise form, expression lambdas, that improves 
> clarity, and method bodies are like statement lambdas, so they should 
> have a concise form too. Maybe that's stretching the connection between 
> statement lambdas and method bodies too thin, but it's a fair starting 
> point. Perhaps the outcome will be classes with a mishmash of method 
> body forms, where the jumping between {} and -> acts to hurt readability 
> overall even if individual methods are simpler. 

Wouldn't those who desire uniformity in this matter be able to achieve 
it in the following way?

public class BankAccount {
    private double balance;
    . . .
    public double getBalance() -> balance;
    public double withdraw(double amount) -> switch(0) { default -> {
       if (amount <= balance) balance -= amount;
       break balance;




Cay S. Horstmann | | mailto:cay at

More information about the amber-spec-observers mailing list