Skip to content

Instantly share code, notes, and snippets.

@Aupajo
Created June 30, 2014 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aupajo/3845b6432d84c6cbeb73 to your computer and use it in GitHub Desktop.
Save Aupajo/3845b6432d84c6cbeb73 to your computer and use it in GitHub Desktop.
require 'time'
june_first = DateTime.new(2014, 6, 1)
june_second = DateTime.new(2014, 6, 2)
june_first > june_second # => false
(june_first..june_second).max == june_second # => true
(june_first..june_second).min == june_first # => true
# Range#max and #min return nil if the first value in range is larger than the last value.
(june_second..june_first).max # => nil
(june_second..june_first).min # => nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment