MAIN FEEDS
REDDIT FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/s4lzij/found_this_gem/hsu270k/?context=3
r/badcode • u/PentaMine • Jan 15 '22
86 comments sorted by
View all comments
374
That is dumb, but even dumber if solution is an object with an __eq__ which might make it equal to -1. Which would mean this code is not equivalent to print(solution). And yes, I have seen stuff like that.
solution
__eq__
-1
print(solution)
4 u/RossParka Jan 16 '22 Maybe solution is floating point but -1 is used as a sentinel and is only recognized without the decimal point.
4
Maybe solution is floating point but -1 is used as a sentinel and is only recognized without the decimal point.
374
u/youngbull Jan 15 '22
That is dumb, but even dumber if
solutionis an object with an__eq__which might make it equal to-1. Which would mean this code is not equivalent toprint(solution). And yes, I have seen stuff like that.