[Newbie] Dolphin Smalltalk Tutorial
Richard A. O'Keefe
ok at atlas.otago.ac.nz
Mon Apr 17 05:15:25 UTC 2000
Michael Chean <Michael_Chean at email.msn.com> wrote:
http://www.object-arts.com/EducationCentre/BeginnersGuide/BeginnersGuide.htm
I tried a number of the samples on this page and the only one I can't get to
work so far is
'Hello world' reverse
I've just thrown together a simple change which appears to do the right thing.
I would greatly value comments on the style of this change.
'From Squeak2.7 of 5 January 2000 [latest update: #1782] on 17 April 2000 at 5:22:09 pm'!
!SequenceableCollection methodsFor: 'copying' stamp: 'raok 4/17/2000 17:20'!
reverse
"Answer a copy of a subset of the receiver, in reverse order"
^self reverseFrom: 1 to: self size
! !
!SequenceableCollection methodsFor: 'copying' stamp: 'raok 4/17/2000 17:19'!
reverseFrom: start to: stop
"Answer a copy of a subset of the receiver, in reverse order.
The first element of the result is (self at: stop) and the last
element of the result is (self at: start)."
|result newSize|
newSize _ stop - start + 1.
result _ self species new: newSize.
(1 to: newSize) do: [:i| result at: i put: (self at: stop-i+1)].
^result! !
More information about the Squeak-dev
mailing list
|