0401 Optionals - Lab에 App Excercise - Food Functions 를 풀어봤는데
답이 맞는지 모르겠어요…
Lab 해 보신 분들, 강사님들 한 번 확인 부탁 드려요…
struct Meal {
var food: [String]
var calories: Int
}
var meals: [String: Meal] = ["Breakfast": Meal(food: ["Bagel", "Orange Juice", "Egg Whites"], calories: 530)]
func mealLog(mealsDictionary: Dictionary<String, Meal>) -> Meal? {
let todayMeals:Dictionary? = mealsDictionary
if let loggedMeal = todayMeals {
print(loggedMeal["Breakfast"]!)
return loggedMeal["Breakfast"]!
} else {
print("nil")
return nil
}
}
mealLog(mealsDictionary: meals)