On Fri, Aug 04, 2006 at 08:22:40PM +0200, florent trolat wrote: > Hi, > > I've define an '=' message for an oject and I want to use this object in > a Collection. > > I've seen that 'incudes:' message use '=' or not '==' and it's not fun > for me! > > I think that '=' message is to compare two objects and '==' to know if > the two object are one! > > So for me 'includes:' must use '==' or not '='... > > May be I have not understand something...
Many kinds of collections use '=' for comparison, but there are also collections that do exactly what you want. For example, an IdentityDictionary is a Dictionary that uses '==' for comparison. Look for classes with "Identity" in their names to see them all. FYI, just as a matter of convention, it is common to refer to the method 'includes:' as #includes, or as '==' as #==. This convention comes about because within Smalltalk, a method selector is a symbol such as #includes:, and this is the way folks usually refer to them in email. I'll also mention that if you implement the #= method, you probably also will want to implement #hash. See the comment in the #= method of class object (which, by the way, would usually be written as Object>>= or Object>>hash in an email). Look at implementors of #hash for examples of what to do. Dave _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners