I was curious about what the difference is between the two.
irb(main):001:0> require 'active_support/core_ext'
=> true
irb(main):002:0> 1.second.from_now == 1.seconds.from_now
=> false
They look the same to me
irb(main):003:0> p 1.second.from_now; p 1.seconds.from_now; nil
2013-06-14 17:50:28 +0530
2013-06-14 17:50:28 +0530
=> nil
And they both have the same class
irb(main):004:0> 1.second.from_now.class == 1.seconds.from_now.class
=> true
Time elapses between both calls, that's why they are different:
Time.now == Time.now
#=> false
Time#to_f
reveals that they are fractions apart:
a, b = 1.second.from_now, 1.second.from_now
a.to_f #=> 1371213500.506212
b.to_f #=> 1371213500.5062568
The call to second
/ seconds
is identical:
1.second == 1.seconds
#=> true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With