Am not doing anything fancy, just trying to use contains method of list.
List<Id> myIdList = new List<Id>();
myIdList.add('0060E000008PdMk');
Id oppId ='0060E000008PdMk';
System.debug(myIdList.contains(oppId)); //Returns false
To my surprise, I spent a few hours debugging and came with this problematic code. Are we not supposed to use contains for List<Id>
?
Changing the type from List<Id>
to List<String>
makes my code run, but I dont have any clue why it does?
Can anyone shed some light?
UPDATE : As per the suggestion of sfdcfox I have raised a case with SF support. Case number "19522568". I will keep you guys updated with the results.
UPDATE 2 : Salesforce reached out to me for this,
A bug W-4884673 already exist for this issue. SF R&D team is working on the same. Known issue link for reference: https://success.salesforce.com/issues_view?Id=a1p3A000000AT9c
There isn't any ETA for this to be fixed, so the case will be closed as "bug fix submitted"
UPDATE 3 : This has now been resolved
oppId == myIdList[0]
.hashCode()
for contains differs from Java List that uses.equals()