RAD Studio (Common)
ContentsIndex
PreviousUpNext
E2239: Default parameter '%s' must be by-value or const (Delphi)

Parameters which are given default values cannot be passed by reference.

program Produce;

  procedure p0(var x : Integer = 151);
  begin
  end;

begin
end.

Since the parameter x is passed by reference in this example, it cannot be given a default value.

program Solve;

  procedure p0(const x : Integer = 151);
  begin
  end;

begin
end.

In this solution, the by-reference parameter has been changed into a const parameter. Alternatively it could have been changed into a by-value parameter or the default value could have been removed.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!