Last active
March 28, 2019 13:36
-
-
Save superswanman/673e574faa8343fa01d7a91e75065c54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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