News for hackers. Stuff that matters.
Re:Reading the Ruby Source to Understand Rails Idiosyncrasies by zhoutong on Saturday July 20, 2013 @07:58PM (#6077095)
I wonder if looking up the source is really necessary. I did some tests with Rails console just now. It seems that Ruby and Rails are handling the case quite logically.

"3.days.ago" at least by default is a TimeWithZone object in Rails.

  3.days.ago.class
   => ActiveSupport::TimeWithZone
And then the way Ruby iterates Range is through the "succ" method. So even this will give you a wall of errors:

  (3.days.ago..2.days.ago).to_a
Sending "succ" to a TimeWithZone object will print a warning because the method is deprecated. So basically a warning will show for every second in the range.

Calling .include? should be equivalent to .to_a.include? in effect.

There are no comments on this comment yet.