Am I immoral for using a variable name that differs from its type only by case?

前端 未结 10 1137
旧时难觅i
旧时难觅i 2021-02-11 11:58

For instance, take this piece of code:

var person = new Person();

or for you Pythonistas:

person = Person()

I

10条回答
  •  误落风尘
    2021-02-11 12:09

    I use this pattern a lot in method signatures. If I'm unable to provide an alternate descriptive name then IMHO, there is nothing wrong with this.

    What is wrong would be if you have two types Person and person then that is very very wrong.

提交回复
热议问题