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

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -