3 ms·
> Because the flip side of monkey patching is the power to do such feats of wonder as 2.days.ago (which returns a date two days back from the current). Now you
by chris_7 10y ago
> Because the flip side of monkey patching is the power to do such feats of wonder as 2.days.ago (which returns a date two days back from the current). Now you might well think that’s a bad trade. That you’d rather lose 2.days.ago if it means preventing programmers from overwriting String#capitalize. If that’s your position, Ruby is probably not for you.
You can implement this stuff in Swift (and C#?) in safe manner. It's not strictly related to "monkey patching", it's just being able to write extensions to type. The issue is with some other library also being able to do that, and them fighting over the behavior.
(2.days.ago is also a weird API as it depends on calendars, etc. - stuff that ought to be explicit)