Fail
Fail a constructor
Declaration
Source position: system.fpd line 95
  procedure Fail;
Description
Fail can be used in a constructor for an object or class. It will exit the constructor at once, and the memory allocated for the constructor is freed. This mean that for objects allocated with New , the resulting pointer is Nil and for classes, the object instance will be Nil.
See also
| Name | Description | 
|---|---|
| Finalize | Finalize (clean up) memory block using RTTI | 
| Initialize | Initialize memory block using RTTI | 
| New | Dynamically allocate memory for variable | 
| TypeOf | Return pointer to VMT of an object | 
Example
program testfail;
{$mode objfpc}
Type
  TMyClass = Class
    Constructor Create;
  end;
Constructor TMyClass.Create;    
begin
  Fail;
end;
var
  M : TMyClass;
begin
  M:=TMyClass.Create;
  Writeln('M is nil : ',Not Assigned(M));
end.