[英]If-else and default condition in groovy script
Is there any way to add default condition into if else loop.有没有办法将默认条件添加到 if else 循环中。 If X is true then operation1 executes else operation2.
如果 X 为真,则 operation1 执行 else operation2。 If X is null then default operation gets executed.
如果 X 为空,则执行默认操作。
if (x)
{ operation1 }
else
{ operation2 }
default
{default operation}
No default null-condition is provided in Java/Groovy as a null
is not treated as default case. Java/Groovy 中没有提供默认的 null 条件,因为
null
不被视为默认情况。
You have to check against the null
yourself:您必须自己检查
null
:
if (null)
{ operationNull }
else if (x)
{ operation1 }
else
{ operation2 }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.