I've got a handful of classes that have a function they've mixed in. The idea is to pass the type into a function that should be instantiated, and the function called, before returning the new object. I've looked around a bit, but I'm still unsure of the best way to do this.
Kind of like:
Obj makeNcall(Type t) {
o := t.make()
o.leadTheCatsToWater() // leading cats is a mixed in trait
return o
}
SlimerDudeSun 9 Mar 2014
Yeah, that should work... just make a dynamic call with the -> operator:
o->leadTheCatsToWater()
or you could use reflection:
Obj makeNcall(Type t) {
o := t.make()
m := t.method("leadTheCatsToWater")
m.callOn(o)
return o
}
inyourcorner Sun 9 Mar 2014
I've got a handful of classes that have a function they've mixed in. The idea is to pass the type into a function that should be instantiated, and the function called, before returning the new object. I've looked around a bit, but I'm still unsure of the best way to do this.
Kind of like:
SlimerDude Sun 9 Mar 2014
Yeah, that should work... just make a dynamic call with the
->
operator:or you could use reflection:
inyourcorner Sun 9 Mar 2014
Got it - thanks!