Hi vladl,
the thing you see in the scripts and your second example is a closure. This is a regular groovy-structure, see
http://groovy-lang.org/closures.html.
Groovy is kind of picky when it comes to places and contexts where methods can be defined and where they can't. For example it's not possible to define them inside of other methods or closures.
Closures on the other hand may basically be defined everywhere. For the other differences between these structures like variable-scope etc. please see the documentation.
I don't know if the scripts are run within a hierachy like a closure of the main program in sexscripts. This is something doti would have to answer. But if this is the case, then methods will not work, but closures will still do. So I suggest you try to use these.
Regards
cgut2001