[ANSI-Smalltalk] Behaviour of #collect:

Ralph Johnson johnson at cs.uiuc.edu
Mon Sep 22 12:35:43 BST 2008


Interval>>collect: always returns an array.  In particular (1 to: 100)
collect: [:each | each + 1] does not return (2 to: 101).  If
String??collect: sometimes returns an array and sometimes a string, it
would make sense for Interval>>collect: to do the same.  So, your
proposed change makes collect: less consistent, not more.  On the
other hand, I can see why you would want String>>collect: to be able
to return arrays.

A good point about your proposal is that you are only changing the
implementation of collect: for cases that now cause an error.  So, it
is unlikely that this change will break any programs that now work.

-Ralph



More information about the ANSI-Smalltalk mailing list