Avatar
omochimetaru 1/18/2019 3:14 AM
extension Int { func formatDecimalStyle() -> String { let formatter = NumberFormatter() formatter.numberStyle = .decimal return formatter.string(from: self as NSNumber)! } } let ids = [89902,100238,123289] let a = ids.map { $0.formatDecimalStyle() }.joined(separator: "|") print(a) // 89,902|100,238|123,289 let b = ids.map(String.init).joined(separator: "|") print(b) // 89902|100238|123289
3:14 AM
initを拡張しなければ未遂に回避できそう (edited)