控制流 / 其他运算符

type
  TWeatherMap = class
  end;

var
  Map: TWeatherMap;

//lazy value: created on first access
function GetWeatherMap: TWeatherMap;
begin
  if Map = nil then
  begin
    WriteLn('2. Creating WeatherMap');
    Map := TWeatherMap.Create;
  end;
  Result := Map;
end;

begin
  WriteLn('1. Before accessing the map');
  GetWeatherMap;
  GetWeatherMap;
  //created only once
end.