Using function arguments as local variables

前端 未结 9 1388
野的像风
野的像风 2020-12-30 03:57

Something like this (yes, this doesn\'t deal with some edge cases - that\'s not the point):

int CountDigits(int num) {
    int count = 1;
             


        
9条回答
  •  被撕碎了的回忆
    2020-12-30 04:08

    If I don't need a copy of the original value, I don't declare a new variable.

    IMO I don't think mutating the parameter values is a bad practice in general,
    it depends on how you're going to use it in your code.

提交回复
热议问题