On Tue, 31 Jul 2012, Patrik Karlsson wrote: > I'm writing a class for Playing cards and would like to compare them with: > =,<,>. > > While hPlayingCard1=hPlayingCard2 works just fine, > hPlayingCard1<hPlayingCard2 and hPlayingCard1>hPlayingCard2 do not. > > The program stops with: > #6: Type mismatch: wanted Number, Date or String, got PlayingCard instead > > My _compare is simple: > Public Function _compare(OtherObject As PlayingCard) As Integer > > Return 0 > > End > > What can I do to make comparing with <,> possible? > > /patrik
If I got the documentation[0] right, the <,> are only valid for the native classes you are given in the error message: Number, Date, String. It is also said[1] that _compare() is used for sorting arrays of objects on a class or finding those. It could likely mean - ignoring the "for example" in that sentence - that these arithmetic operators are not related to the _compare() method. IIRC, there was discussion[2] about a new special method _operator() on the gambas-devel list which will enable you to use any operator on a _native class_. Actually, this seems to be implemented in the gb.gsl classes already. I don't know if it is intended for classes written in Gambas, too. At least, there is no documentation about it (at the usual place) and the commit messages didn't show me anything. [0] http://gambasdoc.org/help/cat/arithop?v3 [1] http://gambasdoc.org/help/lang/special/compare?v3 [2] http://old.nabble.com/About-gb.gsl-components-td34130245.html Regards, Tobi ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user