Skip to content

Instantly share code, notes, and snippets.

@kenechiokolo
Created November 1, 2016 11:47
Show Gist options
  • Save kenechiokolo/8b963b5c4d1e2283be3243c09c1efd57 to your computer and use it in GitHub Desktop.
Save kenechiokolo/8b963b5c4d1e2283be3243c09c1efd57 to your computer and use it in GitHub Desktop.
// 1. Before
static var titles: [String] {
var i = 0
var titles: [String] = []
while let categoryTitle = StudyCategory(rawValue: i)?.title {
titles.append(categoryTitle)
i += 1
}
return titles
}
// 2. After
static var titles: [String] {
let titles = ["General", "Mathematics", "Literature", "Science", "Biology", "Physics", "Business", "Music", "Economics", "Computer Science", "Languages", "Chemistry", "Geography", "Other", "Custom"]
assert(StudyCategory(rawValue: titles.count == nil)
//var i = 0
//var titles: [String] = []
//while let categoryTitle = StudyCategory(rawValue: i)?.title {
// titles.append(categoryTitle)
// i += 1
//}
return titles
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment