Skip to content

Instantly share code, notes, and snippets.

@benlmyers
Created September 13, 2022 23:25
Show Gist options
  • Save benlmyers/e5a36d656fada815068419261a655e36 to your computer and use it in GitHub Desktop.
Save benlmyers/e5a36d656fada815068419261a655e36 to your computer and use it in GitHub Desktop.
//
// Food.swift
// MVVM-SwiftUI
//
// Created by Ben Myers on 9/13/22.
//
import Foundation
/**
An object representing a yummy snack.
Primarily displayed in ``FoodView``.
*/
struct Food: Codable {
// MARK: - Properties
/// The name of the food.
var name: String
/// Whether this is the user's favorite food.
var favorite: Bool
/// An emoji representing the food item.
var emoji: String {
if name.contains("apple") {
return "๐ŸŽ"
} else if name.contains("taco") {
return "๐ŸŒฎ"
} else if name.contains("banana") {
return "๐ŸŒ"
} else if name.contains("soup") {
return "๐Ÿœ"
} else {
return "๐Ÿด"
}
}
// MARK: - Methods
/**
Eat the food.
*/
func eat() {
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment