groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <blackd...@gmx.org>
Subject Re: About declaring the field and property with same name
Date Thu, 13 Jul 2017 07:47:51 GMT


On 13.07.2017 05:44, Daniel Sun wrote:
[...]
> --------------------------------------------
> class Person {
>     String name = '123'
>     private name = 123
> }
>
> new Person().getName().class // class java.lang.Integer
>
> --------------------------------------------
> class Person {
>     String name = '123'
>     private name = 123
>
>     public String getName() {
>         return this.name;
>     }
> }
>
> new Person().getName().class  // class java.lang.String

I think we should set the rule that if you redefine a field for a 
property, you should not be able to define an initializer for both


bye Jochen

Mime
View raw message