The really simplest way to convert List to Set in Salesforce


patlatus

I have seen several publications on topic about what is the simplest way to convert List to Set in Salesforce here
http://www.infallibletechie.com/2012/07/convert-list-to-set-in-salesforce.html?showComment=1392983547327#c4514404938351529437 and here http://sfdc2u.blogspot.com/2013/05/convert-list-to-set-in-salesforce.html?showComment=1392983499131#c6935693483833661663 and was surprised by its complexity and authors ignorance about basic conversion solutions in Salesforce.

To convert List to Set just use

Set<Object__c> tempSet = new Set<Object__c>( tempList );
where tempList is List<Object__c>.

To convert it back, just use
List<Object__c> tempList = new List<Object__c>( tempSet );

View original post