4 ms·
As a Ruby fan who is baffled by Python's continued popularity, I like this comment - I'm always interested to hear why people have such different experiences th
by ezrast 10y ago
As a Ruby fan who is baffled by Python's continued popularity, I like this comment - I'm always interested to hear why people have such different experiences than me trying to move from the former to the latter.
That said, unless "recently" was years and years ago, Date#next_month is a thing:
require 'date'
date = Date.today
while (date < Date.today.next_year)
puts date
date = date.next_month
end
One thing that I think throws a lot of people is that the official Ruby docs are actually better than Google for figuring stuff like this out - it only takes a couple minutes to find #next_month by perusing the method listing at http://ruby-doc.org/stdlib-2.3.1/libdoc/date/rdoc/Date.html http://ruby-doc.org/stdlib-2.3.1/libdoc/date/rdoc/Date.html, but do a web search and you get a bunch of Railsy crap.
Though I will grant you that even searches on ruby-doc.org keep bringing up results for Ruby 2.0.x and whatnot. That part is pretty bizarre.