-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array>>#at:put: should return the stored value #65
Comments
Which of those is the preferred / intended semantics? |
Returning the just stored value seems the most useful semantics to me. |
I have no strong opinions here, but returning the array does allow you to chain |
@krono @fniephaus I checked on SqueakJS, and Squeak returns the value instead of the array. |
Here's what with: firstObject with: secondObject with: thirdObject with: fourthObject with: fifthObject with: sixthObject
"Answer a new instance of me, containing only the 6 arguments as elements."
| newCollection |
newCollection := self new: 6.
newCollection at: 1 put: firstObject.
newCollection at: 2 put: secondObject.
newCollection at: 3 put: thirdObject.
newCollection at: 4 put: fourthObject.
newCollection at: 5 put: fifthObject.
newCollection at: 6 put: sixthObject.
^ newCollection That could of course be rewritten using a cascade. If (Array new: 2)
at: 1 put: true;
at: 2 put: false;
yourself vs. ((Array new: 2) at: 1 put: true) at: 2 put: false |
This is currently inconsistent between different SOM implementations.
The following program should result in the same output for all SOMs:
Current behavior:
instance of Array
43
43
There's also an assumption in #25 that
Array>>#at:put:
returns the value just stored./cc @ltratt
The text was updated successfully, but these errors were encountered: