diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java index 8c7834e9fab..b0384bf5b58 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java @@ -264,9 +264,7 @@ public void run() { boolean isDisabled = RobotState.isDisabled(); // Run scheduled commands, remove finished commands. - for (Iterator iterator = Set.copyOf(m_scheduledCommands).iterator(); - iterator.hasNext(); ) { - Command command = iterator.next(); + for (Command command : Set.copyOf(m_scheduledCommands)) { if (!isScheduled(command)) { continue; // skip as the normal scheduledCommands was modified and that command was canceled }