Created
November 17, 2014 10:35
-
-
Save pbattisson/5ca4ce158baf01ae8002 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///System.TypeException: Invalid conversion from runtime type LIST to LIST | |
List<Object> objects = new List<Object>{'a','a','b','c','c','c','d','e','e'}; | |
List<String> strings = (List<String>)objects; | |
System.debug(strings.size()); | |
//WORKS | |
List<String> stringList = new List<String>{'a','a','b','c','c','c','d','e','e'}; | |
List<Object> objects = (List<Object>)stringList; | |
System.debug(objects.size()); | |
//WORKS | |
List<String> stringList = new List<String>{'a','a','b','c','c','c','d','e','e'}; | |
System.assertEquals(9, stringList.size()); | |
Set<String> stringSet = new Set<String>(stringList); | |
System.debug('String Set Size = ' + stringSet.size()); | |
//Incompatible argument type LIST for All method on SET | |
List<String> stringList = new List<String>{'a','a','b','c','c','c','d','e','e'}; | |
System.assertEquals(9, stringList.size()); | |
Set<Object> objectSet = new Set<Object>(stringList); | |
System.debug('Object Set Size = ' + objectSet.size()); | |
//WORKS | |
List<String> stringList = new List<String>{'a','a','b','c','c','c','d','e','e'}; | |
System.assertEquals(9, stringList.size()); | |
Set<Object> objectSet = new Set<Object>((List<Object>)stringList); | |
System.debug('Object Set Size = ' + objectSet.size()); | |
//WORKS | |
List<Object> objects = new List<Object>{'a','a','b','c','c','c','d','e','e'}; | |
List<String> strings = new List<String>(); | |
for(Object o : objects){ | |
strings.add((String)o); | |
} | |
System.debug(strings.size()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment