<div dir="ltr"><div dir="ltr">Em qui., 6 de jul. de 2023 às 21:18, Nir Lisker <<a href="mailto:nlisker@gmail.com">nlisker@gmail.com</a>> escreveu:<br></div><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div><div>I remember some discussion for "nested methods": allowing methods (and constructors) to contain other methods; I assume that that would be one way to solve it.<br></div></div></blockquote><div><br></div><div>Now that  we have lambdas, many "nested method" solutions are already possible:</div><div><br></div>class Boat {<br>    final int sails;<br>    Boat(Type type) {</div><div class="gmail_quote">        Supplier<int> supplier = () -> {</div>            return switch (type) {<br>                case ENGINE ->  0;<br>                case SAIL -> 2;<br>                default -> 1;<br>            }<br><div class="gmail_quote">        };</div><div class="gmail_quote">        this.sails = supplier.get();<br>    }<br><div>}</div></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Pedro Lamarão</div></div></div></div>