3 ms·
In the last 20 years people realized that the decision of of having nil eat or throw is better made by the caller. To that purpose, several languages already ad
by tangus 4y ago
In the last 20 years people realized that the decision of of having nil eat or throw is better made by the caller. To that purpose, several languages already added a `.?` operator.
That's something that can work also in Smalltalk: Add a class `MessageEatingNil` that returns `nil` to everything except `isNil` and maybe `ifFalse`. Add a method `?` to the root class that returns self. Override that method in the Nil class to return a MessageEatingNil object.
lastNumber := person ? office ? phone ? lastNumberDialed ? asString.
- deleted 4y ago[deleted]