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

前端 未结 10 1136
旧时难觅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:20

    I say name for what it is: if the variable represents a person with 2 dogs, call it personWith2Dogs. It the variable has short scope (like a loop var) then person is fine.

提交回复
热议问题