Runtime evaluation: Difference between revisions

Line 117:
 
====Eval shortcut====
For simple evaluation of string-based scripts with only a few variables (like this one), the '''Eval''' class has static shortcut methods that do the '''Binding''' setup and '''GroovyShell''' evaluation under the surface. '''Eval.me(script)''' evaluates a script with no variables. '''Eval.x(x,script)''', '''Eval.xy(x,y,script)''', andor '''Eval.xyz(x,y,z,script)''' evaluateeach scriptsevaluates a script with 1, 2, andor 3 variables, respectively. Here is an example with start and end years as script variables ''x'' and ''y''.
<lang groovy>def years5 = Eval.xy(2008, 2121, '''
(x..y).findAll {
Anonymous user