0
我有一個不純的功能,像這樣:YARD:文檔無用的或無意的回報
# 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
我要的這個功能做的是建立status
和last_sent
,但這裏的副作用是,它返回Time.now.to_s
。有沒有合適的方法來記錄這一點? 或者是我的函數定義錯誤或應該以return nil
結尾。