Skip to content

Instantly share code, notes, and snippets.

@xjbeta
Last active March 3, 2019 03:54
Show Gist options
  • Save xjbeta/59a65a8350adedb28042f8e6f7515d2c to your computer and use it in GitHub Desktop.
Save xjbeta/59a65a8350adedb28042f8e6f7515d2c to your computer and use it in GitHub Desktop.
Swift format xxx-xxx-xxx -> xxxXxxXxx
import Cocoa
func format(t: [String]) -> [String] {
var tt: [String] = []
t.forEach {
let a = $0.components(separatedBy: "-")
let b = a.map {
a.index(of: $0) != 0 ? $0.capitalized : $0
}.joined(separator: "")
tt.append(b)
}
return tt.map {
"static let \($0) = Aria2Option(rawValue: \"\(t[tt.index(of: $0) ?? 0])\")"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment