request switch statement with common block
Ary Borenszweig
ary at esperanto.org.ar
Sat Aug 3 09:16:22 PDT 2013
On 8/3/13 11:38 AM, JS wrote:
>
> switch (cond)
> common: always executed code here
> case A : etc...
> ....
> }
>
> instead of
>
> if (cond) { always executed code here }
> switch (cond)
> case A : etc...
> ....
> }
>
> which requires modification of the condition twice when necessary
Do you mean this?
switch(cond) {
case A:
common_code();
// something
case B:
common_code();
// something else
}
(common_code() must not be executed if it doesn't hit any switch case)
More information about the Digitalmars-d
mailing list