boolean hasProperty(String property) { return property == "x" } String x = hasProperty("x") ? "Stuff" : null println(x) String y = hasProperty("y") ? "Stuff" : null println(y) // This is not working //String y = if(hasProperty("y")) "Stuff" else null