此处只是一个变化的核对清单,通过它你可以确保你的Groovy classic codebase跟新的Groovy JSR在语法上兼容。
在Classic的Groovy 我们常常使用这样的语法:
class Person = { String name } y = null println "${y->name}" // -> was the optional gpath operator with Classic Groovy syntax
通过安全导航,我们可以避免NullPointerException,但需要使用”?.”操作符来替代箭头(->)操作符。
新的JSR语法是
class Person = { String name } def y = null println "${y?.name}" // Now, ?. is the optional gpath operator the new Groovy JSR