[Solved] How do i get the smallest and highest value of a string? [closed]


Simple, type safe solution:

enum Grade : Double {
    case A = 20.0
    case B = 17.5
    case C = 15.0
    case D = 12.5
    case E = 10.0
    case F = 0.0
}

extension Grade : Comparable {
    static func <(lhs: Grade, rhs: Grade) -> Bool {
        return lhs.rawValue < rhs.rawValue
    }
}

let musicGrade = Grade.A
let bildGrade = Grade.E
let mathGrade = Grade.D

let worstGrade = [musicGrade, bildGrade, mathGrade].min()
print(worstGrade)

solved How do i get the smallest and highest value of a string? [closed]