Skip to content

Commit

Permalink
[PreSmalltalks] Implement Dictionary>>at:putNoSmash:
Browse files Browse the repository at this point in the history
  • Loading branch information
shingarov committed Nov 17, 2024
1 parent 3e2b965 commit d5f6ef5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/PreSmalltalks/Dictionary.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ Dictionary >> anyAt: elementOfKey ifAbsent: absentBlock [
^self at: key
]

{ #category : #'*PreSmalltalks' }
Dictionary >> at: key putNoSmash: anObject [
"Set the value at key to be anObject.
Never smash an existing value: if key already exists, check that
the new value is the same as the old one; if not, raise error."
self
at: key
ifPresent: [ :oldObject | anObject = oldObject ifFalse: [ self error ] ]
ifAbsentPut: anObject.
^anObject
]

{ #category : #'*PreSmalltalks' }
Dictionary >> collectAssociations: aBlock [
^self collect: [ :k_v |
Expand Down

0 comments on commit d5f6ef5

Please sign in to comment.