Swift

Swift

Made by DeepSource

Use shorthand syntax for optional binding SW-C1001

Style
Minor
Autofix

Using shorthand syntax for optional binding can improve the readability and conciseness of your code. The shorthand syntax involves using the if let or guard let statements to bind optional values instead of the longer form of if statements with optional binding.

Using the shorthand syntax can make your code more concise and easier to read. It can also help you avoid nested optional binding, which can improve the overall structure of your code.

Here is an example of using the shorthand syntax for optional binding:

Bad Practice

if let i = i {}

guard let i = i, var j = j else {}

while var i = i { i = nil }

Recommended

if let i {}

guard let i = f() else {}

while var i { i = nil }