Cookcademy 1

I am at the part where it tells us to test our computed property “description”. I get two errors when approaching it two different ways, commented in the code are the errors I get. Type ‘Unit’ has no member ‘none’ and “Global variable declaration does not bind any variables”.

import Foundation

struct Recipe {
    var mainInformation: MainInformation
    var ingredients: [Ingredient]
    var directions: [Direction]
}

struct MainInformation {
    var name: String
    var description: String
    var author: String
    var category: Category
    
    enum Category: String, CaseIterable {
        case breakfast = "Breakfast"
        case lunch = "Lunch"
        case dinner = "Dinner"
        case dessert = "Dessert"
    }
}

struct Ingredient {
    var name: String
    var quantity: Double
    var unit: Unit
    
    
    var description: String {
        let formattedQuantity = String(format: "%g", quantity)
        switch unit{
            case .none:
            let formattedName = quantity == 1 ? name : "\(name)s"
            return "\(formattedQuantity) \(formattedName)"
            default:
            if quantity == 1 {
                return "1 \(unit.singular) \(name)"
            }
            else {
                return "\(formattedQuantity) \(unit.rawValue) \(name)"
            }
            
        }
    }
    
    enum Unit: String, CaseIterable {
        case oz = "Ounces"
        case g = "Grams"
        case cups = "Cups"
        case tbs = "Tablespoons"
        case tsp = "Teaspoons"
        case none = "No units"
        
        var singular: String { String(rawValue.dropLast()) }
    }
    
}

struct Direction {
    var description: String
    var isOptional: Bool
}

var myIngredient = Ingredient(name: "Avocado", quantity: 1.0, unit: .none)

var myIngredientTwo = Ingredient(name: "Avocado", quantity: 1.0, unit: Unit.none)
//Type 'Unit' has no member 'none'

let _ = print(myIngredientTwo.description)


let _ = print(myIngredient.description)
//Global variable declaration does not bind any variables