0

I have an impure function like so:

# Impure function: Sets the status for a report_schedule, uses last_sent to
# calculate status
# @param report_schedule [Hash]
# @return [String] Non-useful: value of last_sent that was set
def self.set_report_schedule_status(report_schedule)
  # Some logic that calculates status of report_schedule
  report_schedule['status'] = status
  report_schedule['last_sent'] = Time.now.to_s
end

What I want this function to do is set status and last_sent, but the side effect here is that it returns Time.now.to_s. Is there a proper way to document this? Alternatively is my function definition wrong or should I just end with a return nil.

Achyut Rastogi
  • 1,335
  • 2
  • 11
  • 15

1 Answers1

0

Should be just adding return nil

Ruby automatically appends return to the last thing executed in a method

Ning Ding
  • 92
  • 1
  • 9