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.
精彩评论