Boolean types

前端 未结 10 2029
时光说笑
时光说笑 2021-01-22 11:54

During code review I discovered many places of our C# code that looks like this:

if(IsValid()) {
     return true;
}
else {
     return false;
}
<
10条回答
  •  逝去的感伤
    2021-01-22 12:40

    I think return IsValid(); is perfectly valid and readable code.

    BTW, I would certainly slap anyone who writes (IsValid() ? true : false) in the face. It's unnecessarily complicated.

    PS. This is what svn blame is designed for.

提交回复
热议问题