If you need to copy method reference between objects at runtime, it is super easy in Groovy. Just add
For some reason this is not very wide known feature (was not for me), and I unsuccessfully tried to use metaClass and other complicated things before finding this.
&
in front of method name and this it. For example:new Expando(id:it.id, user:it.user, mymethod:it.&othermethod, ...)
For some reason this is not very wide known feature (was not for me), and I unsuccessfully tried to use metaClass and other complicated things before finding this.
No comments:
Post a Comment