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) Control Flow If Statement

What is the solution to this? My solution works in xCode but not in the Treehouse editor.

This website is great but is anyone else having difficulty with some of the solutions not being considered correct because of the editor?

My solution:

let months = [1, 2, 3] for month in months { if month == 1 { print("January") } if month == 2 { print("February") } if month == 3 { print("March") } }

1 Answer

Martin Wildfeuer
PLUS
Martin Wildfeuer
Courses Plus Student 11,071 Points

It seems your solution is correct, but you are using print which was introduced with Swift 2 to replace println. This site, however, seems to compile with Swift 1.2. Therefore your code works with Xcode 7, but not in this code editor.

Have a look at the teachers notes with every task, they should highlight the differences.

Moreover, there's a Treehouse workshop video, What's new in Swift 2.0

Always a good read: Ray Wenderlich, What's new in Swift 2

Great! Thanks for your help, I'll check it out!