Author Topic: deleteVariables question  (Read 751 times)

Are you able to delete object variables?
 

Like: deleteVariables("cake.cake*");

No, deletevariables is only for global ($) variables.

No, deletevariables is only for global ($) variables.
Aw. Is there any other way?

.save the object and examine the file or something?

There's no function to delete variables on an object.

You can recreate that object without those variables, but that's really it.

Setting the variables to an empty string removes them from ::dump() listings and from the tagged field list. Not sure if it actually frees them, but it's good enough.

Setting a variable to an empty string flags it as a "deprecated field" which causes it to be skipped in dump but doesn't actually free it. However, deprecating a field should be fine for 99% of uses, and really it should be 100% but the only reason where you'd actually want to clear it beyond this is if you have either insanely long variable names or an insane amount of variables, in both cases you're probably doing something wrong.