ApexSensei

Drills Apex basics

While a queue has work

A while loop repeats as long as its test is true.

Your task

Work through a queue of tasks from the front until it is empty, then show that an empty queue does no work.

List<String> workQueue = new List<String>{ 'Validate', 'Enrich', 'Route' };
Integer processedCount = 0;

List<String> emptyQueue = new List<String>();
Integer emptyProcessed = 0;

Requirements

  1. Processing: Validate and the other two lines should be printed in order
  2. Processed count: 3 should be printed
  3. Remaining work: 0 should be printed
  4. Empty processed: 0 should be printed
  5. while loop should be used that runs while workQueue is not empty
  6. workQueue.remove(0) should be called inside the loop
  7. Processing: Validate should be built at runtime

Sign in to open this drill