Em 23/12/2009 16:10, Eliot Miranda < [email protected] > escreveu:
> > Core.SequenceableCollection comparing > isSameSequenceAs: otherCollection > > "Answer whether the receiver's size is the same as otherCollection's > size, and each of the receiver's elements equal the corresponding > element of otherCollection." > > | size | > (size := self size) = otherCollection size ifFalse: [^false]. > 1 to: size do: [:index | > (self at: index) = (otherCollection at: index) ifFalse: [^false]]. > ^true > > i.e. trust the caller is providing a sequence and if > otherCollection doesn't implement at: there will be a run-time > error, hence any otherCollection isKindOf: SequenceableCollection is > just wasted cycles. > I don't think that "trusting the caller" makes sense in this case, so I propose instead that you implementation be complemented by: Object>>isSameSequenceAs: otherCollection ^false -- Cesar Rabak _______________________________________________ Pharo-project mailing list [email protected] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
