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 trialOmotayo Olawepo
2,803 Pointshelp with code . can't get it to work
using println()
var todo = ["Learn Swift","Build App","Deploy App"]
println("\(todo.count)/")
1 Answer
ianhan3
4,263 PointsYou're close. I think you're sort of trying to use string interpolation, however, you want use that when you want to print a parameter you pass to a function or use a variable inside a longer string. In this case, all you need to do is use .count on todo:
var todo = ["Learn Swift", "Build App", "Deploy App"]
println(todo.count)
ianhan3
4,263 Pointsianhan3
4,263 PointsTo use string interpolation in something like this you can:
This allows your code as well to be easily built upon. I could have just as easily used "I have 3 things to do today" as the String, but what if I added another item to me todo array? I would have to remember that I have to manually update the String to "I have 4 things to do...".
Omotayo Olawepo
2,803 PointsOmotayo Olawepo
2,803 Pointsthanks dude . i get it now