这段代码可以引用块中定义的局部变量、闭包的参数以及创建闭包的作用域中的变量。
This code can refer to local variables defined within the block, arguments to the closure, or variables from the scope in which the closure is created.
然后,在规则的结果块使用该引用,将测试分配给Machine对象。
This reference is then used in the consequence part of the rule to assign tests to the Machine object.
Groovy还实现了方便的默认行为,为名为it的迭代自动提供参数,您可以在代码块中引用。
Groovy also implements the handy default behavior of automatically supplying a parameter for your iteration named it, which you can reference within the code block.
应用推荐