Skip to content

Commit 4956710

Browse files
committed
Replace the single if statement inside the for loop with the for where syntax
1 parent e1dc755 commit 4956710

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

Source/TokenField/ICTokenField.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -385,15 +385,13 @@ open class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDelega
385385

386386
/// Returns true if any highlighted token is found and removed, otherwise false.
387387
private func removeHighlightedToken() -> Bool {
388-
for (index, token) in tokens.enumerated() {
389-
if token.highlighted {
390-
tokens.remove(at: index)
391-
layoutTokenTextField()
392-
togglePlaceholderIfNeeded()
393-
inputTextField.showsCursor = true
394-
delegate?.tokenField?(self, didDeleteText: token.text, atIndex: index)
395-
return true
396-
}
388+
for (index, token) in tokens.enumerated() where token.highlighted {
389+
tokens.remove(at: index)
390+
layoutTokenTextField()
391+
togglePlaceholderIfNeeded()
392+
inputTextField.showsCursor = true
393+
delegate?.tokenField?(self, didDeleteText: token.text, atIndex: index)
394+
return true
397395
}
398396
return false
399397
}

0 commit comments

Comments
 (0)