Now I have a name, the cascades operator.
I don't think the syntax is especially elegant/readable, though.
Now I have a name, the cascades operator.
I don't think the syntax is especially elegant/readable, though.
list := OrderedCollection new
add: 1;
add: 2;
add: 3;
yourself
There's actually a literal syntax for Arrays, but the above example applies to all code and is used heavily in constructors and anything using a builder pattern.Much in the same way as Java, smalltalk-80's arrays are not the most useful thing (they're significantly worse than Java's if I remember correctly, as you can only put other literals in them). So most collections in "user" code are not going to be arrays.
I believe gnu smalltalk extends arrays to be more useful (and adds other collection literals).
What? That's not even close to true. You are misunderstanding something. Actually, I see I think the issue... most Smalltalks have progressed a bit since Smalltalk 80 and now have a fully functional array literal syntax whereas you're talking about the very restrictive original syntax from decades ago.
I'm talking about Smalltalk-80, hence specifying it, but I know Dolphin Smalltalk still has that restriction.