Comparing 2 objects

BlitzMax Forums/BlitzMax Programming/Comparing 2 objects

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hi,

I think you should just use the 'Compare' method.

This exists for every object, and by default just does an address comparison. This at least gives you the ability to do the same thing as 'obj1=obj2', by using obj1.Compare(obj2)=0.

Strings override Compare to do a proper character by character comparison, so you also get proper string behaviour 'for free'.

And of course, other types can provide their own Compare.

Have a look at the mod/brl.mod/linkedlist.mod/linkedlist.bmx source to see how Compare is used to provide a Sort method for lists.