<=>

d other รข -1, 0, +1 or nil
Instance Public methods

Compares the two dates and returns -1, zero, 1 or nil. The other should be a date object or a numeric value as an astronomical Julian day number.

Date.new(2001,2,3) <=> Date.new(2001,2,4) #=> -1
Date.new(2001,2,3) <=> Date.new(2001,2,3) #=> 0
Date.new(2001,2,3) <=> Date.new(2001,2,2) #=> 1
Date.new(2001,2,3) <=> Object.new         #=> nil
Date.new(2001,2,3) <=> Rational(4903887,2)#=> 0

See also Comparable.

doc_ruby_on_rails
2015-04-02 12:23:16
Comments
Leave a Comment

Please login to continue.