Groovy closure – will it work?

Lets say we have Groovy class like this:

  2. class Foo {
  4. def bar(myClosure) {
  5. myClosure(this)
  6. }
  8. private def bas(myName) {
  9. println "hello from ${myName}"
  10. }
  11. }

and I am wonder what should happen if I execute this line of code:

  2. new Foo().bar {
  3. it.bas("Steve Zissou")
  4. }

Should it throw exception that I want execute private method? But this method is execute inside Foo object instance. So, should it print

hello from Steve Zissou

Unfortunately question is still open because Groovy private method / field bug. Or maybe is time to start using Scala and Lift?

    No Comments yet

    RSS feed for comments on this post.

    Sorry, the comment form is closed at this time.

Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds. Valid XHTML and CSS.