this post was submitted on 24 Aug 2025
281 points (97.6% liked)
Programmer Humor
38003 readers
165 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 6 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
How is this implemented? Is it just functions and the language assumes the first parameter is autofilled with variable.function syntax?
Ruby is object-oriented, modelled after Smalltalk mostly. So
So you'll just have implement the method "years" on the Integer (or something more generic like Numeric) class and then "ago" on whatever class the years method returned.
You might imagine that you can do something like 10.years().ago() in python but the parser prevents you:
Doesn't seem like it would have to prevent it, back in ruby:
Ruby is a pretty cute language in my opinion, and I find it sad that python kinda drove over it.
That's just syntax.
Yeah, I figured there would be a workaround. Also
But the other thing is also: can you add methods to the int class so that they're available everywhere? I suspect that you cannot in python, at least without significant hackery. And I also suspect that it's probably something they decided to prevent knowingly.