groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MG <>
Subject Re: Possible New Groovy Features... - var Keyword
Date Tue, 22 Aug 2017 22:52:21 GMT
Hi Paul,

On 21.08.2017 04:30, Paul King wrote:
>     Introduce a "var" (o.s.) keyword that allows deduction of type
>     through assignment:
>     var device = new PrinterDevice(...) // device variable will have
>     type PrinterDevice without the need to explictely state that
>     Rationale: This is a well known feature of other languages, that
>     reduces the need to explictely define the type of variables.

> How is this different to the current type inferencing?

The variable/field will have the type of the initally assigned value 
(instead of Object when using def), therefore one cannot accidentially 
assign any other type to it.


View raw message