How to use switch statement with strings in Pascal

1 Answer

0 votes
program SwitchExample;

uses
  SysUtils;

var
  str: string;
begin
  str := 'Pascal';

  case str of
    'Foo':
      Writeln('Foo');
    'Wii':
      Writeln('Wii');
    'Pascal':
      Writeln('Pascal');
    'YYI':
      Writeln('YYI');
  else
    Writeln('No match found.');
  end;
end.



(*
run:

Pascal

*)




 



answered Jul 1, 2025 by avibootz
...