Custom Ranges in Ruby

21-Apr-2022 1279
You need to generate an array of months between two arbitrary dates. Normally this sort of thing can be solved with a range but date ranges give you an entry for every day, not every month.You could generate all the days and then filter them such that you only keep one per month but that forces you to create a lot more data than you actually need. It also leaves you with an array of Date objects which don’t really represent the concept you are trying to work with.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle