groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edinson E. PadrĂ³n Urdaneta <edinson.padron.urdan...@gmail.com>
Subject Invoking a method/closure/constructor with an arity equal to one without any argument doesn't fail
Date Tue, 01 Sep 2015 06:02:16 GMT
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.

Mime
View raw message