Hello,

I opened that issue: https://github.com/pharo-project/pharo/issues/4442 
<https://github.com/pharo-project/pharo/issues/4442>

And I think to fix it we need to actually discuss about what we want.

#allButFirst: behaves differently depending on the actual type of sequenceable 
collection when argument is greater than collection size.

For instance:

#(1 2) allButFirst: 3.  "PrimitiveFailed signaled"
(LinkedList with: 1 with: 2) allButFirst: 3. "PrimitiveFailed signaled"
(OrderedCollection with: 1 with: 2) allButFirst: 3.  "an OrderedCollection() »

The question is then, who is right?

Should #allButFirst: with an argument greater than the collection size raise an 
error

Or

Should #allButFirst: with an argument greater than the collection size returns 
an empty collection ? 

I asked a few people about it @ ESUG and it appears that the expected behaviour 
from #allButFirst: is not the same to all people.

We need to decide so we improve consistence of collections.

And then, we need to document that with a test :-).

Cheers.

Julien

---
Julien Delplanque
Doctorant à l’Université de Lille
http://juliendelplanque.be/phd.html
Equipe Rmod, Inria
Bâtiment B 40, Avenue Halley 59650 Villeneuve d'Ascq
Numéro de téléphone: +333 59 35 86 40

Reply via email to