rspec/rules/S2197/swift/rule.adoc
Alban Auzeill 2c306d110e Fix code block ambiguity with old header style
Ensure blank line before list and clean the one leading space
2020-06-30 17:16:12 +02:00

27 lines
347 B
Plaintext

include::../description.adoc[]
== Noncompliant Code Example
----
func isOdd(x:Int) -> Bool {
return x % 2 == 1 // Noncompliant; if x is negative, x % 2 == -1
}
----
== Compliant Solution
----
func isOdd(x:Int) -> Bool {
return x % 2 != 0
}
----
or
----
func isOdd(x:Int) -> Bool {
return abs(x % 2) == 1
}
----
include::../see.adoc[]