switch statement

(redirected from Switch case)

switch statement

(Or case statement, multi-way branch) A construct found in most high-level languages for selecting one of several possible blocks of code or branch destinations depending on the value of an expression. An example in C is

switch (foo(x, y)) case 1: printf

The break statements cause execution to continue after the whole switch statemetnt. The lack of a break statement after the first case means that execution will fall through into the second case. Since this is a common programming error you should add a comment if it is intentional.

If none of the explicit cases matches the expression value then the (optional) default case is taken.

A similar construct in some functional languages returns the value of one of several expressions selected according to the value of the first expression. A distant relation to the modern switch statement is Fortran's computed goto.
This article is provided by FOLDOC - Free Online Dictionary of Computing (foldoc.org)
References in periodicals archive ?
What's more, the listing claims that the "Overwatch" Switch case will be released next month, specifically on Sept.
The FSM can be implemented using a switch case. As mentioned before, every request has a unique event-id.
The switch has a large hard plastic actuator, robust construction, four solder terminals and a ground terminal on the switch case. To maximize safety in vacuum pick and place operations, KMS Series have a large flat top in its entirety (i.e., no holes or bumps).
4) This Case/Screen Protector Set: We anticipate lots of manufacturers making their own Switch cases, but Nintendo is obviously the first to get out there and sell one.