Reputation: 231
In rails date subtraction
Date.new(2001,2,3) - Date.new(2001)
#=> (33/1)
what is that /1
indicates?
Upvotes: 1
Views: 1182
Reputation: 97024
It's a Rational
:
(Date.new(2001,2,3) - Date.new(2001)).class
#=> Rational
and this is just how k's are displayed via inspect
:
Rational(1)
#=> (1/1)
if you want an Integer
, then just convert it to one:
(Date.new(2001,2,3) - Date.new(2001)).to_i
#=> 33
Upvotes: 4
Reputation: 13925
This is just a rational number:
(Date.new(2001,2,3) - Date.new(2001)).class
#=> Rational
You just got the number of days between the two date in rational format.
Upvotes: 1