You need to sign in to do that
Don't have an account?
Iteration Order for Maps and Sets Is Now Predictable (Summer 15 Release Update)
Hi Guys,
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.
Thanks.
- 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.
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.
Thanks.
All Answers
Bro... it is still at aschema level.
It is not at in the API Level
Thanks Arun for sharing...
- Harsha