DEV Community

Discussion on: Ruby Tutorial for Python Programmers: how to make the switch

Collapse
 
codeandclay profile image
Oliver

What do you mean by 'cannot modify built-in classes' in Ruby? You can monkey-patch any class in Ruby. What could 'modifying' do that monkey-patching can't?

Collapse
 
djuber profile image
Daniel Uber

I agree - as a concrete example, ActiveSupport adds days to Numbers (or maybe just to integers) so you can say things like 3.days.ago and get and answer that's the same as Time.now - 72.hours (hours is another patch on numbers to handle the conversion).

I suspect that might just have been a typo? I'm not familiar enough with Python to say if it's just those two columns are transposed. Can you modify/override List's __getitem__ in python to change how element access by offset works?