RosettaCodeData/Task/Arrays/Swift/arrays.swift

7 lines
299 B
Swift
Raw Permalink Normal View History

2016-12-05 23:44:36 +01:00
// Arrays are typed in Swift, however, using the Any object we can add any type. Swift does not support fixed length arrays
var anyArray = [Any]()
anyArray.append("foo") // Adding to an Array
anyArray.append(1) // ["foo", 1]
anyArray.removeAtIndex(1) // Remove object
2017-09-23 10:01:46 +02:00
anyArray[0] = "bar" // ["bar"]