Hacker News .hnnew | past | comments | ask | show | jobs | submitlogin

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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: