Getting "extraneous argument label" when trying to append array to other array in Swift
To answer your specific question in the comments, in that case you just need to cast so Swift knows you're aware. In this case since SKShapeNode
downcasts to SKNode
just fine, you can just cast with as
. If you were doing a cast that may fail, you'd need to use as?
and safely unwrap to be sure.
var allNodes: [SKNode] = []let onlyShapeNodes: [SKShapeNode] = []allNodes.append(contentsOf: onlyShapeNodes as [SKNode])
For the original generic example this would work as well.
var array: [Any] = []let test = ["", ""]array.append(contentsOf: [""] as [Any])array.append(contentsOf: test as [Any])