SequenceableCollection has with:do:. Add with: other count: testBlock |r| r := 0. self with: other do: [:x :y | (testBlock value: x value: y) ifTrue: [r := r + 1]]. ^r
I have this in my library anyway. Now distanceStrand1: a strand2: b ^a with: b count: [:x :y | x ~= y] #with:do: already checks that the sequences have the same size; it's too confusing if the error reported in this case is different from the error for #with:do:. On Tue, 15 Sep 2020 at 16:59, Roelof Wobben via Pharo-users < pharo-users@lists.pharo.org> wrote: > Op 14-9-2020 om 22:19 schreef Hernán Morales Durand: > > ^ (1 to: self size) count: [ : i | (self at: i) ~= (aString at: i) ] > > > > With that code I get a few problems but this is working > > distanceStrand1: aString strand2: aString2 > aString size == aString2 size > ifFalse: [ DomainError signal: (self messageFor: aString strand2: > aString2) ]. > ^ (1 to: aString size) > count: [ :i | (aString2 at: i) ~= (aString at: i) ] > > Roelof > > >