groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob Brown <>
Subject Re: Wanted: Help understanding Groovy Syntax for DBUnit Example
Date Fri, 03 Jul 2015 09:30:34 GMT
A meta-level answer to your question:

The most excellent Groovy In Action 2ed is hot off the press, I recommend you get a copy.
All is answered there.


On 3 Jul 2015, at 8:00 am, Richard Heintze <> wrote:

I love this example and it even works!

Can someone help me understand the syntax on lines 29-33? 
(1) What is dataset? Are we passing it a lambda? 

OK, so semi-colons are optional. Hmmm... Apparently we have a list of emp constructors. Is
this correct? 

(2) How is it that the "{}" are constructing a list of emps?

Why is there no code like "[ emp empno:7369, ename:'SMITH', job:'CLERK'
            emp empno:7499, ename:'ALLEN', job:'SALESMAN' 
            emp empno:7521, ename:'WARD', job:'SALESMAN'] as List"?

(3) And what about emp? Who defines the class emp and its constructor? Where?

(4) And what is this business with the grape.grab inside the static {}? I've never seen the
keyword static in groovy code before.  Why static? Why not "@Grab" instead of grapes.grab
(inside the static)?


View raw message