Enumeration & Switch
import UIKit
enum mySchoolGrade{
case English (grade: String)
case Math(grade: String)
case science(grade: String)
case art(grade: String)
func getName() -> String{
switch self{
case .English(let grade):
return grade
case .science(let grade):
return grade
case .Math(let grade):
return grade
case .art(let grade):
return grade
}
}
}
let yourSchoolGrade = mySchoolGrade.English(grade: "A")
print("Your English Grade is: \\(yourSchoolGrade)")
enum yourGradeLevel: Int {
case firstGrade = 1
case secondGrade = 2
case thirdGrade = 3
}
print("Your grade and grade level are", yourSchoolGrade, "and", yourGradeLevel.firstGrade.rawValue)