这个语法是什么意思?

Wel*_*Wel 1 delphi

在这个演示中,我试图弄清楚这个代码是如何工作的,我在这一行停了下来:

type
  TOpenWeatherRequest = (ByCoords);
Run Code Online (Sandbox Code Playgroud)

如何TOpenWeatherRequest定义类型?括号是什么意思?

Ric*_*tor 5

这意味着一个可枚举的类型,作为一个const,您可以在集合中使用,并执行一些逻辑操作.

例如:在国际象棋棋盘中,您可以定义文字名称来表示棋子:

type
  TChessPiece = (cpKing, cpBishop, cpKnight, cpRoque, cpQueen, cpPawn);

var
  Piece: TChessPiece;

Piece := cpBishop;
Run Code Online (Sandbox Code Playgroud)

在课堂上看一个非常有趣的用法

type
  TChessBoard = class
  private
    FPiece: TChessPiece;
  public
    constructor Create(Piece: TChessPiece);
    procedure ShowValidMove;
  end;

implementation

procedure TChessBoard.ShowValidMove; 
begin
   case FPiece of
     cpKing: ShowMessage('Neighboard squares');
     cpBishop: ShowMessage('Diagonal squares'); 
     cpKnight: ShowMessage('L squares'); 
     cpRoque: ShowMessage('Parallel squares'); 
     cpQueen: ShowMessage('Roque AND Bishop squares'); 
     cpPawn: ShowMessage('Goes to front, captures short diagonal');
   end;
end;
Run Code Online (Sandbox Code Playgroud)

看看我对这个问题的回答,我建议使用Enumerable类型来解决一个逻辑矩阵来隐藏一些特定的TabControls 如何在TTabcontrol中隐藏多个标签