rspec/rules/S888/exceptions.adoc

19 lines
466 B
Plaintext
Raw Normal View History

2020-06-30 12:50:59 +02:00
== Exceptions
Equality operators are ignored if the loop counter is not modified within the body of the loop and either:
2020-06-30 12:50:59 +02:00
* starts below the ending value and is incremented by 1 on each iteration.
* starts above the ending value and is decremented by 1 on each iteration.
2020-12-23 14:59:06 +01:00
Equality operators are also ignored when the test is against ``null``.
2020-06-30 12:50:59 +02:00
----
for (int i = 0; arr[i] != null; i++) {
// ...
}
for (int i = 0; (item = arr[i]) != null; i++) {
// ...
}
----