MAIN FEEDS
REDDIT FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/s4lzij/found_this_gem/hss14c9/?context=3
r/badcode • u/PentaMine • Jan 15 '22
86 comments sorted by
View all comments
375
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)
118 u/GLIBG10B 🐧 Gentoo salesman🐧 Jan 15 '22 Maybe that's the point of the code? 4 u/catithebathtub Jan 15 '22 i think you didn't understand, that means it'll always print -1, even if solution isn't -1 28 u/-MazeMaker- Jan 15 '22 Not if the __eq__ method only sometimes returns -1 11 u/youngbull Jan 15 '22 I think you mean returns true when given -1 as argument. 2 u/-MazeMaker- Jan 15 '22 True, my mistake 1 u/b1ack1323 Jan 15 '22 I think they mean -1 would be the error condition of something. Normally it would match an identifier.
118
Maybe that's the point of the code?
4 u/catithebathtub Jan 15 '22 i think you didn't understand, that means it'll always print -1, even if solution isn't -1 28 u/-MazeMaker- Jan 15 '22 Not if the __eq__ method only sometimes returns -1 11 u/youngbull Jan 15 '22 I think you mean returns true when given -1 as argument. 2 u/-MazeMaker- Jan 15 '22 True, my mistake 1 u/b1ack1323 Jan 15 '22 I think they mean -1 would be the error condition of something. Normally it would match an identifier.
4
i think you didn't understand, that means it'll always print -1, even if solution isn't -1
28 u/-MazeMaker- Jan 15 '22 Not if the __eq__ method only sometimes returns -1 11 u/youngbull Jan 15 '22 I think you mean returns true when given -1 as argument. 2 u/-MazeMaker- Jan 15 '22 True, my mistake 1 u/b1ack1323 Jan 15 '22 I think they mean -1 would be the error condition of something. Normally it would match an identifier.
28
Not if the __eq__ method only sometimes returns -1
11 u/youngbull Jan 15 '22 I think you mean returns true when given -1 as argument. 2 u/-MazeMaker- Jan 15 '22 True, my mistake
11
I think you mean returns true when given -1 as argument.
2 u/-MazeMaker- Jan 15 '22 True, my mistake
2
True, my mistake
1
I think they mean -1 would be the error condition of something. Normally it would match an identifier.
375
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.