mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-17 13:38:18 +00:00
Document that using integers in boolean contexts is not recommended
This commit is contained in:
parent
666d9f06a9
commit
9ffde94c86
|
@ -149,6 +149,22 @@ if(Foo) { .. }
|
||||||
|
|
||||||
Unless the alternative code is more complex and harder to read.
|
Unless the alternative code is more complex and harder to read.
|
||||||
|
|
||||||
|
### Using integers in boolean contexts should be avoided
|
||||||
|
|
||||||
|
❌
|
||||||
|
|
||||||
|
```C++
|
||||||
|
int Foo = 0;
|
||||||
|
if(!Foo) { .. }
|
||||||
|
```
|
||||||
|
|
||||||
|
✅
|
||||||
|
|
||||||
|
```C++
|
||||||
|
int Foo = 0;
|
||||||
|
if(Foo != 0) { .. }
|
||||||
|
```
|
||||||
|
|
||||||
### Methods with default arguments should be avoided
|
### Methods with default arguments should be avoided
|
||||||
|
|
||||||
Default arguments tend to break quickly, if you have multiple you have to specify each even if you only want to change the last one.
|
Default arguments tend to break quickly, if you have multiple you have to specify each even if you only want to change the last one.
|
||||||
|
|
Loading…
Reference in a new issue