Created
October 20, 2021 21:50
-
-
Save gitmatheus/86fa366c6d2f33d7544ebf1fc5318213 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************** | |
Imagine three strings: | |
- one with a single space | |
- one null | |
- one not empty and not null | |
******************************************/ | |
String singleSpaceString = ' '; | |
String nullString = null; | |
String notEmptyString = 'Samwise Gamgee is the real hero'; | |
// because, let's be honest... | |
// Now lets concatenate these strings to see | |
// what Salesforce is doing under the hood: | |
| |
String concatenatedText = | |
singleSpaceString + nullString + notEmptyString; | |
// This is the result: | |
| |
|DEBUG|concatenatedText: nullSamwise Gamgee is the real hero | |
// What if we concatenate the empty and null variables only? | |
concatenatedText = singleSpaceString + nullString; | |
// This is the result: | |
| |
|DEBUG|concatenatedText: null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment