【发布时间】:2017-10-13 08:02:47
【问题描述】:
我有一个像这样的不纯函数:
# 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 结尾。
【问题讨论】:
标签: ruby documentation yard