I have this line here, I can not understand the purpose, and the sytacs.
instances = Array(Array(instance.enumerated())[prefixItems.count...])
- What does
... - What does
[prefixItems.count...]when creating anArray? - How
instancescan be assigned to a type like:[(Int, Any)].
this is the whole statement, it is syntactically valid:
let instances: [(Int, Any)]
if let prefixItems = schema["prefixItems"]?.array {
guard instance.count > prefixItems.count else {
return AnySequence(EmptyCollection())
}
instances = Array(Array(instance.enumerated())[prefixItems.count...])
} else {
instances = Array(instance.enumerated())
}
but for some reason I need convert Any to DataToValidate, like:
let instances: [(Int, DataToValidate)]
and then I got error:
Cannot assign value of type 'Array<EnumeratedSequence<(JSONArray)>.Element>' (aka 'Array<(offset: Int, element: JSONValue)>') to type '[(Int, DataToValidate)]'