Enumeration behaviour understanding (Intro to App Development with Swift - Lesson 19) -


i'm new coding , finish "intro app development swift" ibook. in lesson 19, enumerations , switch and, @ page 8 of associated playground shows following code:

enum lunchchoice {     case pasta, burger, soup }  func cooklunch(_ choice: lunchchoice) -> string {     if choice == .pasta {         return "🍝"     } else if choice == .burger {         return "🍔"     } else if choice == .soup {         return "🍲"     }      return "erm... how did here?" }  cooklunch(.soup) 

per se, not problem me understand but, once call cooklunch(.soup), last return statement doesn't show up. exercise below ask me:

try change value passed in cooklunch final else statement called

and got stuck because seems impossible pass different cooklunch function other choices present in enumeration.

could me understand sense behind , maybe provide me solution?

your instructions "so final else statement called". soup return, not "how did here" return. say, 3 lunch choices , 3 if/else statements, 1 of them invoked. have add 4th lunch choice doesn't have corresponding if or else if in order "how did here" code execute.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -