Got an interesting situation where I'm trying to make use of String.split(regExp, limit) to chunk a big list into smaller lists within a loop. However it seems that when the limit is set beyond 11, it will only ever return a list size off 11. Here's an example below:
Integer CHUNK_SIZE = 15;
Set<String> examples = new Set<String> { 'Cats', 'Dogs', 'Ducks', 'Birds', 'Dogs1', 'Ducks1', 'Birds1', 'Dogs2', 'Ducks2', 'Birds2', 'Dogs3', 'Ducks3', 'Birds3', 'Dogs4', 'Ducks4', 'Birds4', 'Dogs5', 'Ducks5', 'Birds6', 'Dogs6', 'Ducks6', 'Birds7', 'Dogs7', 'Ducks7', 'Birds8'};
List<String> chunkedExamples = examples.toString().substringBetween('{', '}').split(',', CHUNK_SIZE);
System.assertEquals(CHUNK_SIZE, chunkedExamples.size());
Is there an issue with the code snippet or am I misunderstanding how the limit input works? Thanks in advance!