[fpc-devel] Abs(Variant) unexpected result
bartjunk64 at gmail.com
Sun Feb 25 22:43:33 CET 2018
On Sun, Feb 25, 2018 at 5:34 PM, Michael Van Canneyt
<michael at freepascal.org> wrote:
>> So, would it be possible to have an overloaded Abs(V: Variant):
>> Variant; function in the variants unit?
> I advise against it.
> S : String;
> S:='My very nice string';
> Will then compile and give a run-time error, as opposed to a compile-time
> error now.
Suggestion from the forum:
function Abs(var V: Variant): Variant; overload;
If (VarIsNumeric(V)) then
if V< 0 then
Result := -V
Result := V
While this will give hints if you did not initialize V, it will not
let you compile Abs(AString).
More information about the fpc-devel