paint-brush
How to quickly get the dates for the first 10 Mondays using Rubyby@FatosMorina
282 reads

How to quickly get the dates for the first 10 Mondays using Ruby

by Fatos MorinaNovember 18th, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

If you are sometimes feeling bored and want to entertain yourself, then rather than aimlessly scrolling in a social media, you can try to learn something new. For example, you can learn something that you have not known that you can do with Ruby: Getting the dates for next <em>Mondays</em>, <em>Tuesdays</em> or any other day of the week.
featured image - How to quickly get the dates for the first 10 Mondays using Ruby
Fatos Morina HackerNoon profile picture

If you are sometimes feeling bored and want to entertain yourself, then rather than aimlessly scrolling in a social media, you can try to learn something new. For example, you can learn something that you have not known that you can do with Ruby: Getting the dates for next Mondays, Tuesdays or any other day of the week.

Here is how you do it:

After you execute it, you will see the list of the dates:

We can replace the part monday with any other name of the days of the week in English and it will work fine.

I know that this may look like something that may not be that much benefit, but maybe, you could use it in a personal script that you have. In a better case, I hope this inspires you to explore more in the documentation of a programming language that you use so that you can learn more hidden gems that can save you a lot of time.