In c# I can do:
object foo = null;
How do I do this in object script?
For simple variables, there isn't a way to set a variable to have an undefined value. Since Cache Object Script has loose typing, it isn't necessary to set an object reference to NULL, it is enough to change the value of the reference to anything else, most commonly empty string, and the garbage collector will clean up the objects for which there is no active reference.
For all practical purposes, setting that variable to empty string "", is enough. If not, can you expand on your question?
Object properties in Cache Object Script never resolve to an undefined value. If the value is undefined (because it has the SQL value of NULL or has never been assigned a value), then the property will resolve to the value of empty string. If you want the property to contain the SQL representation of null, you can do an SQL Insert or Update on the row that corresponds to that object and set the field to NULL. If you set the object's property to empty string and save it, the SQL row for that object will not have NULL, but will have empty string.
Basically, there isn't really an abstract representation of NULL in the object view. There are serialized values for SQL NULL that resolve to NULL in the SQL view and empty string in the Objects view.
Incidentally, the serialized value of NULL in the SQL view is empty string, and the serialized value of empty string is ASCII 0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With