groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <blackd...@gmx.org>
Subject Re: Invoking a method/closure/constructor with an arity equal to one without any argument doesn't fail
Date Tue, 01 Sep 2015 06:09:51 GMT
you miss nothing. This is a logic I wanted to get rid of before Groovy 
1.0 already, but was said to be needed for some special constructs back 
then. And now you cannot easily remove it. But the static compiler does 
not support it, because in the longterm we want to get rid of it

bye blackdrag

Am 01.09.2015 08:02, schrieb Edinson E. PadrĂ³n Urdaneta:
> Hi, everyone.
>
> I'm trying to understand why the following asserts hold
>
> // Method
> def m(def x) { x }
> assert m() == null
>
> // Closure
> def c = { def x -> x }
> assert c() == null
>
> // Constructor
> class Klass {
>      String msg
>
>      Klass(def x) {
>          this.msg = "$x should be null"
>      }
> }
> assert (new Klass()).msg == 'null should be null'
>
> The arity of the method/closure/constructor is one but I can call it
> without any argument at all. What I'm missing?
>
> Thank you in advance.


-- 
Jochen "blackdrag" Theodorou
blog: http://blackdragsview.blogspot.com/


Mime
View raw message