[Newbies] Interval>>copyFrom:to:
Bert Freudenberg
bert at freudenbergs.de
Sat Dec 11 22:10:59 UTC 2010
On 11.12.2010, at 13:58, Ralph Boland wrote:
> Could someone explain why:
>
> (5 to: 100010) copyFrom: 3 to: 1000000
>
> returns an Array rather than an Interval?
Because Interval>>species is Array.
This lets us re-use the generic collection methods instead of having to re-implement them for little benefit.
> Returning an Interval is more intuitive to me
> since the copyFrom:to: message is being sent
> to an Interval.
> Of course, for the the example above at least,
> it is more efficient as well.
It would only be more efficient if it ever got used. Can't imagine a case where this would be useful. It would add complexity to the implementation though.
- Bert -
More information about the Beginners
mailing list