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.5 - Measuring tools
  • 58
  • 0:00
  • 185
Image for Robotics with LEGO - Level 1.5 - Spy games
  • 56
  • 12:47
  • 135
Image for Robotics with LEGO - Level 3.5 - Measuring tools
  • 58
  • 0:00
  • 185
Image for Robotics with LEGO - Level 3.0 - Security systems
  • 50
  • 1:03
  • 213
Image for Lesson 6 - PIN code, Access codes
  • 7
  • 7
  • 20
  • 3d_rotation 1
Image for Robotics with LEGO - Level 4.0 - Kinesthetic and Memory Game (in development)
  • 59
  • 2:58
  • 200
Image for Припомнете си как се работи с условни оператори и кога се използва
  • 3
  • 0
  • 0
  • 3d_rotation 0