E2023 関数には戻り値の型が必要です (Delphi)

提供: RAD Studio
移動先: 案内検索

エラーと警告のメッセージ(Delphi) への移動

関数を宣言しましたが,戻りの型を指定しませんでした。


program Produce;

function Sum(A: array of Integer);
var I: Integer;
begin
  Result := 0;
  for I := 0 to High(A) do
    Result := Result + A[I];
end;

begin
end.

{ 関数 Sum の戻り値の型が指定されていない }


program Solve;

function Sum(A: array of Integer): Integer;
var I: Integer;
begin
  Result := 0;
  for I := 0 to High(A) do
    Result := Result + A[I];
end;

begin
end.

{ 結果の型を必ず指定するだけでよい }