In this demo I was trying to figure out how this code work and I stopped at this lines:
type
TOpenWeatherRequest = (ByCoords);
How a type TOpenWeatherRequest
can be defined like this ? and what the parenthesis mean ?
In this demo I was trying to figure out how this code work and I stopped at this lines:
type
TOpenWeatherRequest = (ByCoords);
How a type TOpenWeatherRequest
can be defined like this ? and what the parenthesis mean ?
that means an enumerable type, something as a const you can use in sets and do some logic operations with.
For example: In a chess board, you can define literal names to represents the piece:
type
TChessPiece = (cpKing, cpBishop, cpKnight, cpRoque, cpQueen, cpPawn);
var
Piece: TChessPiece;
Piece := cpBishop;
Look a very interesting usage in a class
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;
Look my answer for this question, I suggest use Enumerable type to solve a Logic Matrix to hide some specific TabControls How to hide multiple tabs in TTabcontrol