#1767 Instantiate const objects using reflection

dluksza Sun 5 Feb 2012

Is it possible to create const object using reflection ?

For example assume that I have const class like this:

const class Test {
  const Str string
  new make(|This f| f) {
    f(this)
  }
}

how can I create instance of it using reflection ?

dluksza Sun 5 Feb 2012

Never mind I found solution:

f := Field.makeSetFunc([Test#string: "asdf"])
obj := Test#.make([f])

Login or Signup to reply.