Skip to content

Files

Latest commit

 

History

History
46 lines (22 loc) · 629 Bytes

discouraged_optional_collection.md

File metadata and controls

46 lines (22 loc) · 629 Bytes

Pattern: Use of optional collection instead of empty collection

Issue: -

Description

Prefer empty collection over optional collection.

Examples of correct code:

var foo: [Int]


var foo: [String: Int]


var foo: Set<String>


var foo: [String: [String: Int]]


let foo: [Int] = []

Examples of incorrect code:

var foo: [Int]?


var foo: [String: Int]?


var foo: Set<String>?


let foo: [Int]? = nil


let foo: [String: Int]? = nil

Further Reading