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 Enumerations and Optionals Introduction to Enumerations The Problem with Primitives

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 Points

Why am I getting an error?

I'm at 5:26 in the video. Here is my parallel code in my playground:

let week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]

func weekdayOrWeekend(day: String) -> String {
    switch day {
        case "Saturday", "Sunday": return "Weekend"
        case "Monday", "Tuesday", "Wednesday", "Thursday", "Friday": return "Weekday"
        default: return "This isn't a valid day in the Western calendar"
    }
}

func muteNotifications(day: String) -> Bool {
    if day == "Weekend" {
        return true
    } else {
        return false
    }
}

let result = weekdayOrWeekend((week[4])
let isMuted = muteNotifications(result)

I have an error on each of the last two lines.

2nd last line: Expected ',' separator

Last line:

Expected expression in list of expressions

Expected ')" in expression list

Thanks for your help.

1 Answer

Hi Brenden,

It seems you have an extra bracket in the following line of code:

let result = weekdayOrWeekend((week[4])

The extra bracket appears before the "week" variable.

Hope this helps.

Ryan