Lewis Black
Lewis Black

Reputation: 987

How to initialise an array of empty arrays in swift?

My aim is to have an array of empty arrays in swift. Something like this:

[[][][][][]]

They are all of type Game. This is my attempt:

 let numberOfDays = 5
 var gamesCache: [[Game]] = [](count: numberOfDays, repeatedValue: [])

It comes up with the error. Cannot call value of non function type '[Any]'

Upvotes: 2

Views: 976

Answers (1)

Nirav D
Nirav D

Reputation: 72410

Try like this way.

let numberOfDays = 5
var gamesCache = [[Game]](count: numberOfDays, repeatedValue: [])

Upvotes: 7

Related Questions