Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
Java

Journal Zarf's Journal: Mind bending Groovy code

jwagon sent me these mind bending groovy class manipulations in a chat today:

#!/usr/bin/env groovy

class AA {
                def msg
                AA(something){ msg = something }
        }

def c = { a, b ->
  def x =a.newInstance(b)
  println x.msg
}

c(AA, "foo")

Or how about....

#!/usr/bin/env groovy
def m = java.lang.String
def n = m.newInstance("foo")
println n

This discussion has been archived. No new comments can be posted.

Mind bending Groovy code

Comments Filter:

Any program which runs right is obsolete.

Working...