Apex Collections Nesting Depth Documentation Bug

The Apex Developers Guide states that collections (List, Set, and Map) can only be nested up to four levels deep. From the documentation (at the time of this writing):

Lists can contain any collection and can be nested within one another and become multidimensional. For example, you can have a list of lists of sets of Integers. A list can contain up to four levels of nested collections inside it, that is, a total of five levels overall.

I wanted to see what happened if that limit was breached by running this:

List>>>>>> maxDepthTest = new List>>>>>>{
new List>>>>>{
new List>>>>{
new List>>>{
new List>> {
new List> {
new List {


It ran just fine! What gives? Apparently its a bug with the documentation and can be tracked with the bug serial number W-5734219.

2 thoughts on “Apex Collections Nesting Depth Documentation Bug

  1. I bet this is a holdover from many moons ago when Apex was purely runtime interpreted and not compiled that never got removed when the implementation got more flexible. Thanks again for calling it out – nothing makes my day like being able to get rid of documentation for limit we don’t need anymore.

    1. No worries! Thanks for helping to get it routed to the right place. Hopefully getting it removed helps avoid confusion down the road.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.