Swift 2 - Search in string and sum the numbers

前端 未结 1 1907
鱼传尺愫
鱼传尺愫 2021-01-27 23:03

My old code was:

let comps = split(str, { $0 == \"-\" || $0 == \" \" }, maxSplit: Int.max, allowEmptySlices: false)

after update of Swift 2 my

相关标签:
1条回答
  • 2021-01-27 23:37

    The order of arguments for split() function messed up for some reason. It should be:

    let comps = split(str.characters, maxSplit: Int.max, allowEmptySlices: false) {
        $0 == "-" || $0 == " "
    }.map {
        String($0)
    }
    
    0 讨论(0)
提交回复
热议问题