Ruby methods after maths

Not quite sure what to call this post…But in any case:

DateTime.now.end_of_week+7.strftime(“%Y-%m-%d”)

This results in an error; the strftime tries to work on the ‘7’ only, for some reason.

You can fix it by expanding the maths into it’s full form (ie, a method):

DateTime.now.end_of_week.+(7).strftime(“%Y-%m-%d”)

Leave a Reply

Your email address will not be published. Required fields are marked *