Last active
March 3, 2019 03:54
-
-
Save xjbeta/59a65a8350adedb28042f8e6f7515d2c to your computer and use it in GitHub Desktop.
Swift format xxx-xxx-xxx -> xxxXxxXxx
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
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