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?

Bao Pham
PLUS
Bao Pham
Courses Plus Student 240 Points

Help on this Array challenge?

"Print out the number of items in the todo array using println. Part 2 challenge"

Says I have to "Call" the count. When I get the answer wrong.

So, I attempted to write println(todo.count) within the box brackets because the challenge say "in the todo (array) using println." I wrote the println() function in the beginning of the box brackets with a comma at the end.

I am completely stuck as I don't understand where else to type the function.

arrays.swift
var todo = ["Learn Swift","Build App","Deploy App"]
Deron Rowlands
Deron Rowlands
801 Points

You don't need to use box brackets with a println, just curly ones.

The correct answer is simply: println (todo.count)

5 Answers

Bao Pham
PLUS
Bao Pham
Courses Plus Student 240 Points

So apparently I was right and so were all of you except we all forgot one symbol. The semi-colon.

It was supposed to be this.

var todo = ["Learn Swift", "Build App", "Deploy App"]; println(todo.count)

I don't even remember the video showing use of that symbol. I will go back and check the video again.

AR Ehsan
AR Ehsan
7,912 Points

Try! var todo = ["Learn Swift", "Build App", "Deploy App"] println(todo.count)

AR Ehsan
AR Ehsan
7,912 Points

var todo = ["Learn Swift", "Build App", "Deploy App"] println(todo.count)

Bao Pham
PLUS
Bao Pham
Courses Plus Student 240 Points

I've tried all the above answers. I get this in response.

You need to call the 'count' method on the array.

Bao Pham
PLUS
Bao Pham
Courses Plus Student 240 Points

So apparently I was right and so were all of you except we all forgot one symbol. The semi-colon.

It was supposed to be this.

var todo = ["Learn Swift", "Build App", "Deploy App"]; println(todo.count)

I don't even remember the video showing use of that symbol. I will go back and check the video again.