Interval>>copyFrom:to:

Richard A. O'Keefe ok at cs.otago.ac.nz
Thu May 30 01:36:17 UTC 2002


In Squeak 3.0, if you do
	(1 to: 12) allButFirst
you get an array, not the Interval I was expecting.

There are a whole lot of "slicing" methods in SequenceableCollection
which end up calling #copyFrom:to:.  The default implementation builds
an instance of "self species new".

It's pretty obvious how I could fix this to work the way I'd expect:

Interval>>"in category 'copying'"
copyFrom: firstIndex to: lastIndex
   self assert:
      [firstIndex >= 1 and: [lastIndex between: firstIndex-1 and: self size]].
   ^self class
      from: (firstIndex - 1) * step + start
      to: (lastIndex - 1) * step + start
      by: step

My question is whether (1 to: 12) allButFirst is SUPPOSED to return an Array
for some reason, or whether this was an inintended consequence of an
incomplete edit?  Has this been changed later?  (I keep waiting for the
announcement of 3.2final...)



More information about the Squeak-dev mailing list