Basic & probably stupid question.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Basic & probably stupid question.

nacho
Hi Folks,
I'm trying an example from Inside Smalltalk vol.1

When I try to print:

| anArray |
anArray _ Array new.
anArray at: 1 put: 'hello'; at: 2 put: 'nacho'; at: 3 put: 'pepito'.

I receive:
subscript is out of bounds: 1
Where as according to the book I should receive the 3th element.

The same happens when I try to print:
| anArray |
anArray _ Array new.
anArray at: 1 put: 'hello'; at: 2 put: 'nacho'; at: 3 put: 'pepito'; yourself.

which according to the book should return anArray.

is the at:put: selector different in Cuis?
Thanks in advance
Nacho
Nacho Smalltalker apprentice. Buenos Aires, Argentina.
Reply | Threaded
Open this post in threaded view
|

Re: Basic & probably stupid question.

nacho
I figured it out.
It was indeed a stupid question.
Arrays are fixed so I should do:
anArray _ Array new: 3.

cheers
Nacho Smalltalker apprentice. Buenos Aires, Argentina.