Why does i|= j|= k|= (j+= i) - - (k+++k) - - (i =+j) == 11?

后端 未结 4 1873
挽巷
挽巷 2020-12-22 14:33

I came across this code in a project I have started working on. The original developer is no longer available, and I can\'t make any sense of it:



        
4条回答
  •  礼貌的吻别
    2020-12-22 15:36

    To me, the best answer is Mike Rylander's (in comment).

    Replace it with return 11; and commit.

    I mean, the code is not dependent on anything written before, so it produces 11 everytime. It is a complex computation that takes time for nothing and produces 11. So you just have to return 11. Do not keep the useless code of a developper who was obviously having fun on you. It reminds me of a former colleague, who set a bomb in the code (something that seldom crashes, but sometimes crashes indeed), just before resigning...

    Note : There might be a case where it is not equivalent: if i, j, and k are visible outside your method and reused somewhere else. But it is highly unlikely.

提交回复
热议问题