Groovy dynamic property per object
问题 Using Groovy 1.8. I'm trying to create a dynamic class definition that will cache properties per object. I did use propertyMissing without adding the property to the object just fine. I just think caching the properties would be more efficient. Right? Note that each instance must have its own different properties. The code below works fine: class C {} def c = new C() c.metaClass.prop = "a C property" println c.prop def x = new C() x.prop will output: a C property groovy.lang