- November 1, 2018 at 12:45 pm #51458
what is the difference between empty and null ?
Is there any difference between null and empty?November 1, 2018 at 10:46 pm #51487Adam #301
Another one to test us on 🙂
From the outside the difference can appear very slight. But to code that is running, it could mean very different outcomes!
In coding (once again I am assuming it is in the context of APEX), something could be NULL because it doesn’t exist or hasn’t been instanciated (ie it hasn’t been created/setup).
Where as empty has two possible outcomes/possibilities. It could mean that it is a string/text (as an empty) that is nothing. For example ”. There is nothing in between the ‘ and the ‘. But the code has allocated memory to the variable, even if there isn’t any actual text stored. Additionally, it could also mean NULL (see above).
The Salesforce documentation also makes note of ‘blank’ which essentially has three possible outcomes: that whitespace is stored in the field, that ” is stored in the field, or NULL. So when using forumals in Salesforce, I always try to use ISBLANK(), as it is the most ‘inclusive’ of the three functions.
Please Register to reply to this topic. /