Salesforce Fact #817 | Map put() method return
The put() method of Map class returns null if it's a new key-value pair which is added. However, if the key was already existing, then put() method returns the old value. This might be helpful when we want to know the old value while replacing the value corresponding to a key. Reference: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_map.htm#apex_System_Map_put Attached is the screenshot.