How to initialize a 2D array full of zeros in swift?

Just use the array initializer (repeating: , count: ) as follows:

var rows = 3 
var column = 5 
var arrayOfArrayInitialization = [[Int]](repeating: [Int](repeating: 0, count: column), count: rows)

That’s all my people, I hope you liked reading this article as much as I enjoyed writing it. If you want to support this blog you can Buy Me a Coffee or just leave a comment saying hello. You can also sponsor posts and I’m open to freelance writing! You can reach me on LinkedIn or Twitter and send me an e-mail through the contact page.

Thanks for the reading and… That’s all folks.

 

Learn More Algorithms

If you want to continue studying algorithms you can check the solution to find the symmetric difference. Also, the inventory update problem where we use a dictionary to resolve a really tricky question.

 

Image Credit: Wikiart

Share this post:

Related posts

Sponsor