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 methodMissing
Date Mon, 11 Jan 2016 12:49:38 GMT


Am 11.01.2016 um 10:32 schrieb 杨文强:
[...]
> String classText = "class DynamicGroovyClass { def methodMissing(String name, args) {println
\"You called $name with $args\"  args.size()  } }";

you will require a newline or a semicolon after the println to let 
Groovy know you started a new command. Otherwise Groovy will assume you 
wanted to create a commandexpression, in which case your code translates to:

println ("You called $name with $args").args.size()

and since println is a void method it tries to do null.args resulting in 
that NPE

bye Jochen

Mime
View raw message