[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: _Compare, passes array to single value compare.. Bug?


Le 11/07/2024 à 01:24, Brian G a écrit :
_compare is used during sorting, it will only pass the same datatype, but if it is a variant and the datatype is an array of the datatype it should not be getting passed into the _compare. It look like an actual but to me. It fails if an attempt to pass any other data type is passed.

Pretty sure that an array of Crmpit[] is not the same as crmpit when it comes to a sort.


It's not really a bug, but more the way it is designed.

When you compare two objects, and the first one has a '_compare' method, this method is called with the second object as argument.

Note: if the first object has no '_compare' method, but the second one has it, the '_compare' method of the second object is called with the first object as argument.

But there is no datatype check at all before calling '_compare()'. It's up to '_compare()' to declare its argument with the expected datatype if you want an error when the class of the second object is incorrect.

Unless someone finds a real bug, I don't think I will change that, as it allows to declare a comparison method for two different classes if you need it.

Regards,

--
Benoît Minisini.


References:
_Compare, passes array to single value compare.. Bug?Brian G <brian@xxxxxxxxxxxxxxxx>
Re: _Compare, passes array to single value compare.. Bug?Bruce Steers <bsteers4@xxxxxxxxx>
Re: _Compare, passes array to single value compare.. Bug?Brian G <brian@xxxxxxxxxxxxxxxx>