groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul King <pa...@asert.com.au>
Subject Re: Possible New Groovy Features... - var Keyword
Date Thu, 24 Aug 2017 13:32:10 GMT
The same argument applies to this as to the 'the type of final fields from
their assigned value' case.
So, possible perhaps within @CompileStatic contexts.

On Wed, Aug 23, 2017 at 8:52 AM, MG <mgbiz@arscreat.com> wrote:

> 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.
>
> Cheers,
> Markus
>
>
>

Mime
View raw message