假设我有一个字符串
let string = "ABHJGDFHJWGHJFSHJCKVHDSK"
我需要将输出数组作为["AB","HJ","GD","FH","JW","GH","JF","SH,"JC","KV","HD",SK"]
如何在swift中实现这一目标?
我试过但输出似乎不同
let inputCharacterArray = string.characters.map { $0 }
let pairs = stride(from: 0, to: inputCharacterArray.count, by: 2).map {
(inputCharacterArray[$0], inputCharacterArray[$0.advanced(by: 1)])
}