Skip to content

Files

Latest commit

 

History

History
55 lines (24 loc) · 593 Bytes

empty_collection_literal.md

File metadata and controls

55 lines (24 loc) · 593 Bytes

Pattern: Missing use of isEmpty

Issue: -

Description

Prefer checking isEmpty over comparing collection to an empty array or dictionary literal.

Examples of correct code:

myArray = []


myArray.isEmpty


!myArray.isEmpy


myDict = [:]

Examples of incorrect code:

myArray == []


myArray != []


myArray == [ ]


myDict == [:]


myDict != [:]


myDict == [: ]


myDict == [ :]


myDict == [ : ]

Further Reading