通常のGroovyスクリプトが与えられた場合、スクリプト自体の内部で定義されたクラスからそのバインディング変数にアクセスする方法はありますか?
次のスニペット
class Example {
def printBindings() {
for (var in binding.variables) {
println "$var.key - $var.value"
}
}
}
new Example().printBindings()
以下の例外で失敗します:
groovy.lang.MissingPropertyException: No such property: binding for class: Example