Converting a string into an object reference

Is there an easy way to convert a string that refers to an object within nested classes/tables to a genuine object reference? For example if I have a string “myclass.mytable.myelement”, I’d like to convert that to the reference myclass.mytable.myelement

I can’t find the appropriate syntax to pull this off, instead I’m using a simple function to resolve the reference.

function resolve(pathArray){
// given a stringarray , it converts it into an object reference
// only if its parent references are valid
// eg “myclass.mytable.myelement” becomes myclass.mytable.myelement
local object = this;
foreach (element in pathArray){
if (element in object)
object = object[element];
return null;
return object;

strRef <- “”;

objectRef <- resolve(split(strRef,"."));

That’s what I would do (and have done many times before).