Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift Basics (retired) Collections What is an Array?

Mehran Amini Tehrani
Mehran Amini Tehrani
1,523 Points

Array

Hello,

How can I print out the number of items in the todo array using println? I know for counting I need to write for example: todo. count, but it does not work.

arrays.swift
var todo = ["Learn Swift", "Build App", "Deploy App"]
todo. count

4 Answers

Here's a link.

The println function prints the value as a string.

var todo = ["Learn Swift", "Build App", "Deploy App"]

println(todo.count)

Remember that the ebook "The Swift Programming Language" by Apple is a great (and free) resource on Swift, and you can learn a lot just by skimming through the first chapter.

Mehran Amini Tehrani
Mehran Amini Tehrani
1,523 Points

Thanks for your response... How can I get that book?

Great!