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
David FryDavid Fry 

Question about List of Lists

I'm working with list of lists and there is a syntax I'm seeing that I'm not familiar with.  Can someone clarify what this is doing?
 
List<List<sObject>> myListOfLists = New List<List<sObject>>();
myListOfLists = [SOME SOSL QUERY];

List<myObject> oneList = New List<myObject>();

oneList = ((List<myObject>)myListOfLists[0]);
The section in bold is what I don't understand is happening?  Can someone explain?   It almost looks like it's casting the first list as my new list type but I'm not sure.
Thanks for the help.
 
Vinod Chokkula 3Vinod Chokkula 3
Since myListOfLists is a List<List<Sobject>> myListOfLists[0] returns one list, which you are casting into a specific List
David FryDavid Fry
Ok so it is the Syntax of "casting".   I've never seen it done that way, I come from a vb background.  Thanks!