Last Updated: February 25, 2016
·
725
· sheerun

Don't use include? for checking if Date is in Range

Following will instantiate every date between start_date and end_date, and then check if date is in that set:

(start_date..end_date).include?(date)

That could take a while. Instead use:

(start_date..end_date).cover?(date)

It uses >= and '<=' methods on Range boundaries.