function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JJamesJJames 

List.Contains equivalent in apex code?

I am wondering if there is any extension that I might not be seeing in the soap api guide that would be the equivalent to list.contains so that I can check if an item already exists in a list.  Or is there a simple way to do this besides checking each item of the list everytime?

Thanks
Best Answer chosen by JJames
Andy BoettcherAndy Boettcher
The List collection does not have a .contains(), your best bet is to iterate through the List and put it in a Map (or just start from a Map!) and that has a containsKey().

All Answers

Andy BoettcherAndy Boettcher
The List collection does not have a .contains(), your best bet is to iterate through the List and put it in a Map (or just start from a Map!) and that has a containsKey().
This was selected as the best answer
JJamesJJames
okay that's what I figured, thanks.