The Default Case of a Switch block used as a switch statement Pro Preview

Sometimes, it may happen that the value passed to a switch statement block does not match any of the foreseen cases. Which case of the switch is going to be executed? None? The first one?

To access the full video please subscribe to FLLCasts.com

Subscribe

  • #1172
  • 22 Mar 2019

Then, the default case is executed when the data evaluated by the switch block does not match any of the cases. The default case is one of all given cases and is marked with a dot:

 You can change the default case by just selecting any other case as shown:

NOTE: if you delete the defaut case, the first case will become default:

A good practice is to have a case with a value that can not be met, usually -1. That case is set to default and covers any errors and unexpected data. Within the case you can put a sound block with "Error" or some other notification for the occured error.

Courses and lessons with this Tutorial

This Tutorial is used in the following courses and lessons

Image for Robotics with LEGO - Level 3.0 - Security systems
Course icon fllcasts
  • 47
  • 0:00
  • 206
Image for Lesson 6 - PIN code, Access codes
Lesson icon fllcasts
  • 7
  • 7
  • 19
  • 3d_rotation 1
Image for Robotics with LEGO - Level 3.5 - Measuring tools
Course icon fllcasts
  • 58
  • 0:00
  • 185
Image for Robotics with LEGO - Level 3.5 - Measuring tools
Course icon fllcasts
  • 58
  • 0:00
  • 185
Image for Robotics with LEGO - Level 1.5 - Spy games
Course icon fllcasts
  • 50
  • 5:17
  • 123