Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jpluimers/f9db5497259e3f0ea6bcec9bf654603f to your computer and use it in GitHub Desktop.
Save jpluimers/f9db5497259e3f0ea6bcec9bf654603f to your computer and use it in GitHub Desktop.
type
TObjectHelper = class helper for TObject
public
class function &&op_LogicalOr<T: class>(A, B: T): T; static;
end;
class function TObjectHelper.&&op_LogicalOr<T>(A, B: T): T;
begin
if A <> nil then
Result := A
else
Result := B;
end;
procedure Test;
var
sl1, sl2, sl3: TStringList;
begin
sl1 := nil;
sl2 := TStringList.Create;
sl3 := sl1 or sl2; // -> sl3 = sl2
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment