0
func test(input: String) -> Bool {
    let reversed = input.reversed()
    let inputArray = Array(input)
    
    return reversed == inputArray 
}

I am getting the error Cannot convert value of type 'ReversedCollection<String>' to expected argument type '[String.Element]' (aka 'Array<Character>') from compiler with above function

BUT same function without properties as below, directly comparing works perfectly, Can someone explain me with details please ?

func test(input: String) -> Bool {
   return input.reversed() == Array(input)    
}
ayfer
  • 39
  • 6

0 Answers0