Skip to content

Instantly share code, notes, and snippets.

@freeonterminate
Created November 10, 2015 02:34
Show Gist options
  • Save freeonterminate/f7a9180681cd40436487 to your computer and use it in GitHub Desktop.
Save freeonterminate/f7a9180681cd40436487 to your computer and use it in GitHub Desktop.
[tips] C like case-sentence
program CLikeSwitchCase;
function SwitchCase(const A: Integer): Integer;
label
Case0, Case1, CaseElse;
begin
Result := 0;
case A of
0: goto Case0;
1: goto Case1;
else goto CaseElse;
end;
Case0:
Inc(Result);
Case1:
Inc(Result);
CaseElse:
Inc(Result);
end;
begin
Writeln(SwitchCase(0)); // 3
Writeln(SwitchCase(1)); // 2
Writeln(SwitchCase(2)); // 1
Readln;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment