Search code examples
rubydateactivesupport

Change the month of a Date object without returning a new date


Is there a way to change the month of a Date object without returning a new object?

Because Date.now.change and Date.now += 1.month return new date objects.


Solution

  • No, "all date objects are immutable" see https://ruby-doc.org/stdlib-2.5.0/libdoc/date/rdoc/Date.html