Just for the sake of "academics", it is possible to call a dynamic method using only expressions, but it requires some gymnastics that some would consider onerous.

For instance:

<cfscript>
foo = createObject("component","foo");
methodToCall = "getStuff";
foo.tempMethodName = foo[methodToCall];
result = foo.tempMethodName();
structDelete(foo,"tempMethodName");
</cfscript>

That last step is optional, since there's not much harm in having the tempMethodName floating around (it won't be in the meta data, for instance).

I'm not advocating this as "good" code, necessarily, but it works fine and given that methods pass by reference it isn't expensive. Whether you consider it "readable" and/or "clean" is a matter of taste, I suppose.

 - Nathan


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]


Reply via email to