You need to sign in to do that
Don't have an account?
cool 183
collections
Can anyone please give me a real time scenario where we use set in apex code to retrieve unique details. As list gives all data including duplicates, and I have used only list in my codings. So I do not want a code but a scenario where set only should be used and not the list..
Collections have their own properties and Functionality,If you are not aware of it then, Please First Understand the Properties and Functionality,
and Definitely You will get an Idea when to Use them
Please Follow Below URL
http://www.sfdc99.com/2014/04/06/example-how-to-write-an-advanced-trigger/
http://www.iterativelogic.com/salesforce-apex-trigger-best-practices/
- You can perform DML operations.
- It is ordered and have duplicates ( As Sura said also in bulk DMLs you can have errors)
Sets :- Sets we use actually for the unique values.
- You cannot perform DML with Sets.
So if you want unique values in a list, put the values in a set and then populate a list from the set.OR
Use MAP this is my favorite.
For maps go to this link https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_collections_maps.htm