metaprogramming - Groovy Meta Programming with getter method -
would me figure out why added "get" method works 1 class(string) not other class(node)?
string.metaclass.getfoo = { "string foo" } s = "test" println s.foo // works: "string foo" node.metaclass.getfoo = { "node foo" } xml = "<test><body>test</body></test>" nodes = new xmlparser().parsetext(xml) println nodes.foo // not work: gets [] how make calling "foo" resulting same getfoo() class node?
nodes.foo try find element in parsed tree of nodes. directly using getfoo() option afaik.
Comments
Post a Comment