Created
November 1, 2016 11:47
-
-
Save kenechiokolo/8b963b5c4d1e2283be3243c09c1efd57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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