Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.269 Beiträge
 
Delphi 12 Athens
 
#29

AW: case .. of kann kein break - Gibt es dafür einen rationalen Grund?

  Alt 10. Mai 2024, 05:36
Wobei das auch schon im Basic so war (ohne Break), sowie auch COBOL (außer dass dort das CASE noch EVALUATE hieß), Algol und anderen Delphi/Pascal-Vorfahren.
Also eigentlich war es garnicht seine Idee.

Joar, Strings wären auch mal was.

Delphi-Quellcode:
uses System.StrUtils, Vcl.Dialogs;
type TTheCase = (blubb, blob, wuppdi);
const cTheCase: array[TTheCase] of string = ('blubb', 'blob', 'wuppdi');

procedure TForm1.FormCreate(Sender: TObject);
begin
  var S := InputBox(Application.Title, 'Was: ' + string.join(' ', cTheCase), 'mähhh');
  case TTheCase(IndexStr(S, cTheCase)) of
    blubb, blob: ShowMessage('Juhu: ' + S);
    wuppdi: ShowMessage('Hihooo: ' + S);
    else ShowMessage('Nööö: ' + S)
  end;
end;
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests

Geändert von himitsu (10. Mai 2024 um 05:44 Uhr)
  Mit Zitat antworten Zitat