groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <blackd...@gmx.org>
Subject Re: [RFE] Methods as expressions
Date Tue, 20 Mar 2018 17:09:14 GMT
I think my issue with this is similar to the problem I had recently with 
something Daniel suggested: It seemed to be part of a bigger picture, 
but the bigger picture is missing.

Am 20.03.2018 um 11:41 schrieb Cédric Champeau:
> Hi,
> 
> One of the Kotlin features I really like is the short-hand notation for 
> simple expression methods:
> 
> class Foo {
>      fun truth(): Integer = 42
> }
> 
> For example, in Groovy, you write:
> 
> @Controller("/") class HelloController {
>      
>      @Get("/hello/{name}")
>      String hello(String name) {
>          return "Hello $name"
>      }
> }
> 
> 
> but we could write:
> 
> @Controller("/")
> class HelloController {
>      @Get("/hello/{name}")
>      String hello(String name) = "Hello $name"
> }
> 
> 
> It's more concise and makes the "functional style" more readable. Is 
> this something Groovy users would appreciate?
> 

Mime
View raw message