Is there any specific reason why salesforce did not provide list.contains in apex method

230    Asked by Aashishchaursiya in Salesforce , Asked on May 2, 2023

Is there any specific reason why salesforce did not provide list.contains() method.

The below methods are added to List class and are available after Spring 18 release to Sandboxes and Production instances.

System.List Class

1) contains(listElement) Returns true if the list contains the specified element.


2) indexOf(listElement) Returns the index of the first occurrence of the specified element in this list. If this list does not contain the element, returns -1.

Link to official documentation

Answered by anu rhea
You can now use List.contains() in apex with Spring 18 https://releasenotes.docs.salesforce.com/en-us/spring18/release-notes/rn_apex_new_classes_methods.htm#rn_apex_new_classes_methods


Your Answer

Interviews

Parent Categories