7
I have been dabbling in Python for some time now and have written some really easy apps. But I alway...
since 2 years, 10 months ago
2 of 2
Tip Reveddit Real-Time can notify you when your content is removed.
your account history
Tip Check if your account has any removed comments.
view my removed comments you are viewing a single comment's thread.
view all comments


No, an orange.eat method would make sense unless it was an animated orange.
A tree could, maybe, have an eat method, which could deplete the soil from nutrients. Then, yes, maybe the orange could have an eat that ate from the tree, but probably an overkill.
To clarify, in theory you can do it either way, human.eat(orange) etc but what you see is classes with the interesting methods declared on the object it happens to. UI programming is rife with this stuff.
In any case the orange isn't really an interesting object type in itself. You can say well, it's a fruit but what does that even mean? A strawberry is a fruit (or is it) but you don't need to peel it. They both grow on plants but that's not really relevant. It's a philosophical argument about objects, categories, attributes etc that is above most people's pay grade, basically.
What about clementines, mandarins or tangerines?
Really an orange is just an orange because we all agree it is, due to the fuzzy computational ability that our brains have but computers don't. The code can treat something like an orange but it doesn't really matter if it's a lemon, except it might taste funny after you peel it and eat it. That's more like duck typing.