How is it that describes seem to return case-insensitive maps? For instance, if I create a new custom setting, the following succeeds:
Map<String, SObjectField> fields1 = SObjectType.MySetting__c.fields.getMap(); system.assert(fields1.containsKey('Id'));
yet the following fails:
Map<String, SObjectField> fields2 = new Map<String, SObjectField>(); fields2.putAll(SObjectType.MySetting__c.fields.getMap()); system.assert(fields2.containsKey('Id'));
However, their keysets are the same, as the following will pass:
In both cases, the keyset is:
Clearly, only the lower case version of the string
'id' is in the map.
The same behavior seems to hold for
The above described behavior seems to violate the basics of how maps work in
Apex. Is this in fact the same data structure? Can it be constructed by hand? It would potentially be useful, for instance, in parsing parameters on a page or REST service without needing to do some sort of loop through the keys with a case-insensitive comparison.