Until the Spring 15 release, Maps and Sets are Unordered Collections. So the returned order will be random. But beginning from Summer 15 release onwards, Maps and Set order is predictable. The order will be same that what you put from the beginning to end.
Example:
Map<String, String> orderedMap = new Map<String, String>();
orderedMap.put('Good', 'This is so good');
orderedMap.put('Bad', 'This is so bad');
System.debug(orderedMap);
If you run the above code snippet in Developer console you will get the returned order as below,
Until Spring 15 Release:
{Bad=This is so bad, Good=This is so good}
From Summer 15 Release:
{Good=This is so good, Bad=This is so bad}
This changes is not the API level, this is Schema level change. If anyone relying on the Map or Set order in your codes, change it as soon.
Reference:
http://releasenotes.docs.salesforce.com/en-us/summer15/release-notes/rn_apex_maps_and_sets_iteration_order.htm
https://help.salesforce.com/apex/HTViewSolution?id=000213516&language=en_US
Example:
Map<String, String> orderedMap = new Map<String, String>();
orderedMap.put('Good', 'This is so good');
orderedMap.put('Bad', 'This is so bad');
System.debug(orderedMap);
If you run the above code snippet in Developer console you will get the returned order as below,
Until Spring 15 Release:
{Bad=This is so bad, Good=This is so good}
From Summer 15 Release:
{Good=This is so good, Bad=This is so bad}
This changes is not the API level, this is Schema level change. If anyone relying on the Map or Set order in your codes, change it as soon.
Reference:
http://releasenotes.docs.salesforce.com/en-us/summer15/release-notes/rn_apex_maps_and_sets_iteration_order.htm
https://help.salesforce.com/apex/HTViewSolution?id=000213516&language=en_US
No comments:
Post a Comment