swift2 - cannot invoke reduce with an argument list of type swift 2.0 -
when upgrade swift 1.2 swift 2.0 following error occurs
cannot invoke reduce argument list of type
here code
let escaped = reduce(string, "") { string, character in string + (character == mark ? "\(mark)\(mark)" : "\(character)")
can me how solve problem
reduce()
method collections such arrays have call on list of characters can access using characters
property of string, not on whole string itself:
let escaped = string.characters.reduce("") { string, character in string + (character == mark ? "\(mark)\(mark)" : "\(character)") }
Comments
Post a Comment