I always like to find a way not to make the choice.

#(1 2) allButFirst: 3 ifInsufficient: [���]

allButFirst: N
^self allButFirst: N ifInsufficent: [ ���fight about this"].

��� Kasper


On 30 August 2019 at 12.28.14, Cyril Ferlicot (cyril.ferlicot@gmail.com) wrote:



On Fri 30 Aug 2019 at 09:34, Julien <julien.delplanque@inria.fr> wrote:
Hello,


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 :-).

Hi,��

I was one of the person who discussed this with Julien at ESUG and IMO it should launch an error.��

While working on complexe models, errors in such cases are really really really helpful to find bugs. Errors such as SubscriptOutOfBound or NotFound help me a lot to find bugs and sometimes without this kind of methods it could have take me days to find the problem (and it���s only in the case I know there is a bug).


Cheers.

Julien

---
Julien Delplanque
Doctorant �� l���Universit�� de Lille
B��timent B 40, Avenue Halley 59650��Villeneuve��d'Ascq
Num��ro de t��l��phone: +333 59 35 86 40

--
Cyril Ferlicot
https://ferlicot.fr