当前位置:   article > 正文

Groovy 条件语句_groovy if else

groovy if else

在groovy中支持如下 条件语句

1:if/else if/else

  1. if ( ... ) {
  2. ...
  3. } else if (...) {
  4. ...
  5. } else {
  6. ...
  7. }

2:switch / case

Groovy中的switch语句向后兼容Java代码

Switch supports the following kinds of comparisons:

  • Class case values match if the switch value is an instance of the class

  • Regular expression case values match if the toString() representation of the switch value matches the regex

  • Collection case values match if the switch value is contained in the collection. This also includes ranges (since they are Lists)

  • Closure case values match if the calling the closure returns a result which is true according to the Groovy truth

  • If none of the above are used then the case value matches if the case value equals the switch value

switch

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/人工智能uu/article/detail/810364
推荐阅读
相关标签
  

闽ICP备14008679号