Ruby: Don't raise error on date.strftime() if date is nil -
One such case is when the code is called on zero
I disagree.
This is the Datetime.strftime
method. Indeed, this is considered to be formatted in the string in the date time
object.
Then it must be understood that
datetime = Time.now Datetime.strftime ('% d-% m-% Y') # = & gt; '17 -10-2014 'datetime = zero datetime.strftime ('% d-% m-% Y ') # = & gt; Instead I need to always write: datetime.strftime ('% d-% m-% Y') If the date time
> Which is a pain.
I think many unexpected behavioral series should come in the middle after calling a method on the blue, but in that situation, I do not see much danger. A string is returned anyway, and the result is quite logical: (empty_date) .to_s => empty_string
Can I avoid this behavior?
I disagree with you.
A zero value, which is a method called on it, which is kept in helpless codes, flow, or a situation which has not been adequately validated.
I do not know why your special case should be treated as an exception here. Your price is zero, and you are trying to call a method that does not exist. QED
Comments
Post a Comment