[LRUG] Comparable Null Objects

Michael Pavling pavling at gmail.com
Wed Jul 15 06:01:11 PDT 2015


On 15 Jul 2015 15:29, "Michael Pavling" <pavling at gmail.com> wrote:
>
> Instead of including `Comparable`, set your `NoExpectedDate` class to
inherit from `Date` (keep the overloads of `.to_s` and `.<=>`)

Though you need to change your `.<=>` method to return -1 for sensible
results in the console, but this approach makes both evaluations treat your
NoExpectedDates as older than any other date, which may be the opposite of
what you want.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20150715/93a06d45/attachment-0003.html>


More information about the Chat mailing list