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

  1. Casino Games - Dr. MSD
    The number one spot for the best Vegas casino is Hard 김천 출장샵 Rock 광양 출장샵 Hotel & 광주 출장마사지 Casino & Spa. We have our Vegas casino games, from slots to 과천 출장안마 video 인천광역 출장마사지 poker,

    ReplyDelete

Post a Comment