July 2013
Intermediate to advanced
370 pages
8h 27m
English
We can achieve some level of fluency simply using a Groovy feature that allows commands, or method calls, to be chained. Groovy does not require parentheses when methods take arguments. Also, if a method returns a result, we can make subsequent calls on that instance without using a dot (.). Using simple plain-vanilla Groovy code, with no metaprogramming magic, we can execute fluent code like the following:
| CreatingDSLs/CommandChain.groovy | |
| | move forward and then turn left |
| | jump fast, forward and then turn right |
That looks like a data file, but it’s 100 percent executable Groovy code. Let’s analyze it and figure out the Groovy code needed to execute it.
In the first line, we don’t have any commas. Groovy will ...
Read now
Unlock full access