Reputation: 67
I am using SwiftLint in my app. I am getting Control Statement Violation: if
, for
, guard
, switch
, while
, and catch
statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses. (control_statement).
What is wrong with that code? Why i am getting that waring?
Thanks in Advance
for i in 0..<images.count {
if(i == images.endIndex - 1) {
print(i)
}
}
Upvotes: 4
Views: 8468
Reputation: 1396
Its simply telling parentheses start ( and parentheses end ) symbols are now not necessary to provide in control statement' conditions so your code will go without () in control statement conditions for example your code will look like below
for i in 0..<images.count {
if i == images.endIndex - 1 {
print(i)
}
}
Upvotes: 6
Reputation: 17409
You have added parentheses in if condition. Remove it.
for i in 0..<images.count {
if i == images.endIndex - 1 {
print(i)
}
}
You can check detail rule here.
Upvotes: 3