Reversed method not rendering on Array

Hello Stack Overflow!

I am learning methods in SWIFT and haven't been able to get the .reversed method to print out the actual reverse of an array on line 39. The .reverse method is working, however.

screenshot: https://drive.google.com/file/d/1wa0FGz605I-0Cle_5Oid0uAWXfXp95K2/view?usp=sharing

I have tried rewriting the code and double checked that it matches what the instructor has typed into Xcode as well.

Any insight is appreciated! TY

1 answer

  • answered 2020-01-14 02:05 DrewG23

    .reversed() is actually returning a ReversedCollection instead of an array. Source

    To turn this back into an array you can try:

    print(characterClasses.reversed().map({ $0 }))
    

    or

    print(Array(characterClasses.reversed()))