I created this helper in order to add some more functions to the string
type:
type
AStringHelper = record helper for string
function Invert: string; overload;
function InvertMe: string; overload;
end;
But when I use it in my code, the TStringHelper
in System.StrUtils
"gets out" and I can't use it's functions.
Is it possible to both of them to coexist?
Another possibility is to use the "Ancestor list" option offered by helpers
Syntaxis:
And use like this:
And finally, in your code:
At most one helper can active at any one point in your code. The documentation says this:
Since record helpers do not support inheritance, there's no way to have both the standard helper's and your helper's functionality active at the same time, other than re-implementing the standard helper's functionality.
A simple solution to this could be:
By using type casting you can access the functions on
TStr
on a ordinarystring
variable:But of course, then we can ask: Why not just write an ordinary function? :-)
Anyway, I like this
class
/object
/record
method syntax better than traditional function/procedure.Try to create your own class and helper
Use TMyString instead of String.
To use standard String helpers wrap TMyString variable with String() or use ToString method.