.isEmpty
Christine_Yang271 total contributions
Published Oct 11, 2022
Contribute to Docs
The .isEmpty
property will return a true value if there are no key-value pairs in a dictionary and false if the dictionary does contain key-value pairs.
Syntax
dictionaryInstance.isEmpty
Example
var bakery = [String:Int]()print(bakery.isEmpty)bakery["Cupcakes"] = 12print(bakery.isEmpty)
In the example above, the bakery
dictionary is checked if it .isEmpty
; once when it is initiated, and again when a key-value pair is added. This will output:
truefalse
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.