MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/uz3eo7/welcome_to_hassle_free_coding/ia7voay
r/ProgrammerHumor • u/SuchShopping3828 • May 27 '22
305 comments sorted by
View all comments
108
Welcome to "why the hell is this function returning a string and not an object like it's supposed to?"
42 u/MarchColorDrink May 27 '22 Tbf, a string is an object. A function is an object. A class instance is an object. It's all objects. 30 u/Dolner May 27 '22 Some would even say object oriented 19 u/MarchColorDrink May 27 '22 I object! 7 u/scuac May 28 '22 Hearsay! 0 u/mbardeen May 27 '22 True.. however that one function can return different type objects than one expects is annoying at best, and dangerous at worst. 1 u/PewPew_McPewster May 28 '22 So I can print(function(n)), duh. 1 u/MatsRivel May 28 '22 Type hints are a thing, and they are pretty good. They'll give you a notification if you've fucked up the input/output types, but will still let you run it.
42
Tbf, a string is an object. A function is an object. A class instance is an object. It's all objects.
30 u/Dolner May 27 '22 Some would even say object oriented 19 u/MarchColorDrink May 27 '22 I object! 7 u/scuac May 28 '22 Hearsay! 0 u/mbardeen May 27 '22 True.. however that one function can return different type objects than one expects is annoying at best, and dangerous at worst.
30
Some would even say object oriented
19 u/MarchColorDrink May 27 '22 I object! 7 u/scuac May 28 '22 Hearsay!
19
I object!
7 u/scuac May 28 '22 Hearsay!
7
Hearsay!
0
True.. however that one function can return different type objects than one expects is annoying at best, and dangerous at worst.
1
So I can print(function(n)), duh.
Type hints are a thing, and they are pretty good. They'll give you a notification if you've fucked up the input/output types, but will still let you run it.
108
u/mbardeen May 27 '22
Welcome to "why the hell is this function returning a string and not an object like it's supposed to?"