The method add: in the class Set return an error if the parameter is nil.
Maybe, we can return nil and manage the error outside the method.
| index |
newObject ifNil: [self error: 'Sets cannot meaningfully contain nil as an element'].
index := self findElementOrNil: newObject.
(array at: index) ifNil: [self atNewIndex: index put: newObject].
^ newObject
---
We can do something like this. (the same as VisualWorks)
---
| index |
newObject ifNil: [^newObject].
index := self findElementOrNil: newObject.
(array at: index) ifNil: [self atNewIndex: index put: newObject].
^ newObject
---