I'm trying to learn some smalltalk programming.... I'm trying to create a list of objects of type myClass. What's the best way to do this?
I have the following:
| list |
list := OrderedCollection new.
Correct me if I'm wrong.
So how should I add elements to my list?
To create new instances of MyClass send the class the message #new
MyClass new
Now, to add an element to a collection, just send the collection the message #add:
list add: MyClass new
There is no such a thing as static types in Smalltalk. In other words, the equivalent of the Java ArrayList<MyClass> is just OrderedCollection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With