[LRUG] Comparable Null Objects

James Mead james at floehopper.org
Fri Jul 17 03:51:46 PDT 2015


I just came across the undocumented Date::Infinity class [1] which
might be of some relevance to this thread.

[1]: https://github.com/ruby/ruby/blob/c8b3f1b470e343e7408ab5883f046b1056d94ccc/ext/date/lib/date.rb#L7..L58

On 17 July 2015 at 00:53, Paul Makepeace <paulm at paulm.com> wrote:
> On Thu, Jul 16, 2015 at 3:24 PM, Stephen Best <bestie at gmail.com> wrote:
>>
>> events.sort_by { |e|
>>   e.date { heat_death_of_the_universe }
>> }
>>
>
> This to me is the clearest of the proposals (Tom's role idea is cool too).
>
> For a null object you could also use... nil
>
>   events.sort_by { |e|
>     e.date || date_that_sorts_at_the_end  # (named to be clearer about intent)
>   }
>
> The whole discussion has been really interesting!
>
> Paul
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> Archives: http://lists.lrug.org/pipermail/chat-lrug.org
> Manage your subscription: http://lists.lrug.org/options.cgi/chat-lrug.org
> List info: http://lists.lrug.org/listinfo.cgi/chat-lrug.org



More information about the Chat mailing list