How to call final return statement in function taking in enum argument?

Hi guys, first post here. Please refer to pic. Thanks.

Hi!

Well, you just found out why enums are great! What you want to do is basically cover all the cases in your enum exhaustively.

Since you found out, that if statements don't really let you do that, you can turn to the switch statement, which is expressly made for this purpose:

switch choice {
case .pasta:
    return "Pasta"
case .burger:
    return "Burger"
case .soup:
    return "Soup"
}
// At this point the compiler knows you have covered all cases 
// and no return statement is needed!

Have a look at https://docs.swift.org/swift-book/LanguageGuide/Enumerations.html for more information. Enums are among the greatest things in Swift, and they will surely grow on you :slight_smile:

I think the exercise wants them to add a new case to the enum, rather than change the code logic. Switch statements are probably covered later.

The if statement is currently checking for every case of the LunchChoice enum, which makes it impossible to ever hit the return statement ... so try adding another choice of food and think about what is happening then.

OHH yes this is the answer I was looking for! Thank you to both of you for your help! :grin: