Smart pascal source code
Type
TMyRecord = Record
mrId: Integer;
mrObj: TObject;
End;
var mRec: TMyRecord;
if not Assigned(mRec.mrObj) then
WriteLn('not assigned');
if Assigned(mRec.mrObj) then
WriteLn('assigned');
WriteLn(mRec.mrId);
mRec.mrObj := TObject.Create;
mRec.mrId := 12;
WriteLn(mRec.mrObj.ClassName);
WriteLn(mRec.mrId);
mRec.mrObj := NIL;
mRec.mrId := 0;
if mRec.mrObj <> nil then
WriteLn('assigned');
if mRec.mrObj = nil then
WriteLn('not assigned');
WriteLn(mRec.mrId);
{<<< RESULT - CONSOLE LOG >>>
-----------------------------
not assigned
0
TObject
12
not assigned
0
-----------------------------
{<<<<<<<<< THE END >>>>>>>>>}
function Copy$TMyRecord(s,d) {
d.mrId=s.mrId;
d.mrObj=s.mrObj;
return d;
}
function Clone$TMyRecord($) {
return {
mrId:$.mrId,
mrObj:$.mrObj
}
}
var mRec = {mrId:0,mrObj:null};
/* <<< main JS >>> */
if (!mRec.mrObj) {
WriteLn("not assigned");
}
if (mRec.mrObj) {
WriteLn("assigned");
}
WriteLn(mRec.mrId);
mRec.mrObj = TObject.Create($New(TObject));
mRec.mrId = 12;
WriteLn(ClassName$1($ToClassType(mRec.mrObj)));
WriteLn(mRec.mrId);
mRec.mrObj = null;
mRec.mrId = 0;
if (mRec.mrObj!==null) {
WriteLn("assigned");
}
if (mRec.mrObj===null) {
WriteLn("not assigned");
}
WriteLn(mRec.mrId);