Fun Code of the Day #2: Does nil have a type?
Okay, no cheating now. That is, no running the code until you’ve guessed.
What is the output of this code?
program Project90;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
var
S: TObject;
begin
try
S := nil;
if S is TObject then
begin
Writeln('Yup');
end else
begin
Writeln('Nope');
end;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
Readln;
end.
How sure are you?
Now run it and find out. Were you right?
Original author: This email address is being protected from spambots. You need JavaScript enabled to view it.