📄 ternaryoperatortest.groovy
字号:
class TernaryOperatorTest extends GroovyTestCase { void testSimpleUse() { def y = 5 def x = (y > 1) ? "worked" : "failed" assert x == "worked" x = (y < 4) ? "failed" : "worked" assert x == "worked" } void testUseInParameterCalling() { def z = 123 assertCalledWithFoo(z > 100 ? "foo" : "bar") assertCalledWithFoo(z < 100 ? "bar" : "foo") } def assertCalledWithFoo(param) { println "called with param ${param}" assert param == "foo" }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -