Skip to content

Instantly share code, notes, and snippets.

@superswanman
Last active March 28, 2019 13:36
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save superswanman/673e574faa8343fa01d7a91e75065c54 to your computer and use it in GitHub Desktop.
Save superswanman/673e574faa8343fa01d7a91e75065c54 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