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 2.0 Collections and Control Flow Control Flow With Conditional Statements Recap: Control Flow with Conditional Statements

Aditya Gawade
Aditya Gawade
1,182 Points

need help. is the problem so that constant has month but switch statement has monthS?

Next Question A The above code will not compile because switch statements need to be exhaustive with case statements for all expected values or a default statement. B The code is valid and isn't missing anything. C It's missing case statements for the rest of the months.

1 Answer

Hi Aditya the issue in the statement, all values, in this case months 1 - 12 must have a case OR a default statement. Either all have a case or at least add a default. Thought if you do decided to add a case to all values, then there would be no need to add a default value.

The above code will not compile because switch statements need to be exhaustive with case statements for all expected values or a default statement.