Array Count in Swift

Level 122 keystrokes

Prints the number of elements in the array [1, 2, 3] using count: 3.

Swift code

// count on an array literal returns how many elements it has: 3
1print([1, 2, 3].count)

Output

3
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Swift code and how often they appear.

  • ,× 2
  • .× 1
  • (× 1
  • )× 1
  • [× 1
  • ]× 1

More Swift examples at level 1

← Swift typing practice