Copy link to clipboard
Copied
How do you loop over the properties of an object?
I have this CFC and I have properties defined
<cfscript>
...
property name="firstname" getter="true" setter="true" type="string";
property name="lastname" getter="true" setter="true";
---
</cfscript>
I'm trying to loop over these properties and trim the values.
Thanks,
-ws
Copy link to clipboard
Copied
First thing that popped into my mind was looping over a collection.
Copy link to clipboard
Copied
Yes, me too, but what would be syntax. I can dump the object and I see the properties and the methods, but how do I loop over the properties within the CFC.
I'm looking for specific syntax that would allow me to loop over the properties in a CFC.
-ws
Copy link to clipboard
Copied
I'm not in front of my computer to verify this, but I'm pretty sure properties aren't automatically exposed as a collection. You need to use getMetadata() and they're exposed in the returned struct.
I think.
--
Adam