Swift .count

Christine_Yang's avatar
Published Oct 11, 2022
Contribute to Docs

The .count property returns an integer that represents how many key-value pairs are in a dictionary.

  • Learn how to build iOS applications with Swift and SwiftUI and publish them to Apples' App Store.
    • Includes 7 Courses
    • With Certificate
    • Beginner Friendly.
      13 hours
  • A powerful programming language developed by Apple for iOS, macOS, and more.
    • Beginner Friendly.
      12 hours

Syntax

dictionaryInstance.count

Example

var fruitStand = [
"Apples": 12,
"Bananas": 20,
"Oranges", 17
]
print(fruitStand.count)
// Output: 3

All contributors

Contribute to Docs

Learn Swift on Codecademy

  • Learn how to build iOS applications with Swift and SwiftUI and publish them to Apples' App Store.
    • Includes 7 Courses
    • With Certificate
    • Beginner Friendly.
      13 hours
  • A powerful programming language developed by Apple for iOS, macOS, and more.
    • Beginner Friendly.
      12 hours