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 trialsimondumalski
3,875 PointsIm Stuck on Swift Basics Collections
I'm trying to print out todo but I am having problems doing that. It also says that I need to use todo.count, but I don't know why.
var todo: [String] = ["Learn Swift","Build App","Deploy App"]
todo.count
println\(todo)
miguelcastro2
Courses Plus Student 6,573 PointsThe key to solving this is using Loops, perhaps re-watch those videos. Here is an example of looping over the array and printing each item:
for item in todo {
println("Current Item => \(item)")
}
To use todo.count you will need to create a for loop with a counter.
1 Answer
Max Hirsh
16,773 PointsHey simondumalski,
Your answer is really close. All you need to do is directly print "todo.count", not just call it in the previous line. println works for both numbers and strings.
Connor Besancenez
781 PointsConnor Besancenez
781 PointsI believe you would just need to print out the array like this
println(todo)