[LRUG] Comparable Null Objects

Stephen Best bestie at gmail.com
Thu Jul 16 15:36:47 PDT 2015


On 15 July 2015 at 13:03, Duncan Stuart <dgmstuart at gmail.com> wrote:

> Can I get NoExpectedDate to pretend to be a Date (like SimpleDelegator
> lies about it's class)? Is that evil?
>
I'd like to make the point that SimpleDelegator doesn't exactly lie about
its class, call `#class` on an instance and you'll get exactly what you
expect. The issue is that it has no `#inspect` method, so when printed on
the console, `#inspect` is delegated and it masquerades as the the object
being wrapped .

This has caught me out several times in the past, so I quite often add an
inspect method myself.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20150716/2c06bf6a/attachment.html>


More information about the Chat mailing list