Hello all, pardon my beginner language,
I'd like to know if anybody knows a clean solution for the following problem (possibly avoiding
reduce(...) or any further iteration over the array ). And would also like to know the reasons (if there are any) for this behaviour:
Defining a simple typealias on
Identifier, and assigning a
[String] var to
[Identifier] var works smoothly.
reversed() is applied on first array tho, the product is a
ReversedCollection<[String]> and such type cannot be assigned to a
[Identifier] var anymore, receiving following error from compiler:
Cannot convert value of type 'ReversedCollection<[String]>' to specified type '[Identifier]' (aka 'Array')
TLDR; Isn't this behaviour un-coherent? Is there a practical reason for the compiler to refuse this? Is there a clean workaround?
typealias Identifier = String /// compiles let arr3 = [String]() let arr4: [Identifier] = arr3 /// does not compile let arr1 = [String]().reversed() let arr2: [Identifier] = arr1 // << error
Thank you for your time.