开发者

Get the newest and oldest date from a list - Ruby

I have an array of Ruby Dat开发者_开发百科e objects. How can I find the newest datetime and the oldest datetime?


date_array.min # => Oldest
date_array.max # => Most recent


oldest, newest =  date_array.minmax


You have a comparison operator:

http://www.ruby-doc.org/core/classes/Date.html#M000673

Sort it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜