Simple ways to disable parts of code

后端 未结 14 1439
误落风尘
误落风尘 2021-01-31 08:59

This isn\'t a typical question to solve a specific problem, it\'s rather a brain exercise, but I wonder if anyone has a solution.

In development we often need to disable

14条回答
  •  别跟我提以往
    2021-01-31 09:05

    I'm not sure I should post this because it's not something I think is 'good code', but I'll admit to having used the following technique as a quick-n-dirty way to be able to quickly switch between two small snippets of code when I'm just checking something out:

    // in the following , foo() is active:
    /**/ foo(); /*/ bar(); /**/
    

    Now just remove one of the asterisks at the front:

    // now bar() is active:
    /*/ foo(); /*/ bar(); /**/
    

    Of course, this should never make it past the "just checking things out" phase...

提交回复
热议问题