groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gerald Wiltse <jerrywil...@gmail.com>
Subject Behavior of .with() inside Trait
Date Wed, 10 Feb 2016 15:52:45 GMT
This example returns the error inside the with closure:

      "No such property: cow for class:Bar"

It seems .with() in a trait does not resolve the way it "normally" does.


trait Foo {
    def action() {
        println binding.cow
        binding.with {
            println cow
        }
    }
}

class Bar implements Foo {
  Binding binding = new Binding()
}


def myBar = new Bar()
myBar.binding.cow = "says moo"
myBar.action()


If anyone has any insight, it would be helpful.


Gerald R. Wiltse
jerrywiltse@gmail.com

Mime
View raw message