简体   繁体   English

在Groovy闭包中逗号是什么意思?

[英]What does comma mean in this Groovy Closure?

I found the following expression: 我发现以下表达式:

 { i -> module BookRow, $("table#book-results tbody tr", i) }

in Modelling repeating structures with Geb page objects article . 用Geb页面对象建模重复结构”中的文章

Inside this Groovy closure, you have a call to a module method that takes two arguments: BookRow and $("table#book-results tbody tr", i) . 在此Groovy闭包内,您可以调用带有两个参数的module方法: BookRow$("table#book-results tbody tr", i) Groovy actually allows to omit parentheses for top-level statements, and here, the comma separator actually separates the two arguments of this module method call. Groovy实际上允许省略顶级语句的括号,在这里,逗号分隔符实际上分隔了此module方法调用的两个参数。

ie. 即。 foo a, b is equivalent to foo(a, b) . foo a, b等效于foo(a, b)

If you wanted to separate two statements on the same line, you'd use semi-colons: foo(); bar() 如果要在同一行上分隔两个语句,则可以使用分号: foo(); bar() ;。 foo(); bar() . foo(); bar()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM