groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <blackd...@gmx.org>
Subject Re: 答复: Lambda expression for Groovy 3
Date Wed, 19 Oct 2016 13:03:31 GMT


On 19.10.2016 14:12, daniel_sun wrote:
> Hi Rémi,
>
>      Groovy can choose the right method to call :)
>
> assert ['1', '2', '3'] == [1, 2, 3].collect(Integer.&toString)

I am sure that works only because the static Integer.toString(int) and 
the virtual Integer.toString() return the same values. If you look at

> class X {
>   def foo() {1}
>   static foo(X x) {2}
> }

Then for a X.&foo covering virtual and static methods, there is no way 
of knowing if we want to call the virtual foo or the static foo method. 
Both would take and instance of X as argument.

bye Jochen

Mime
View raw message