import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
yeTyeArray()
}
func yeTyeArray(){
let myArray = ["charmander","bulbasaur","squirtle"]
print("---1.随机获取数组中的一个元素,myArray.random():\(String(describing: myArray.random()))")
let myArray2 = ["charmander","bulbasaur","squirtle","charmander"]
print("---2.获取某个元素在数组的索引, myArray2.indexesOf(charmander):\(myArray2.indexes(of: "charmander"))")
let myArray3 = ["charmander","bulbasaur","squirtle","charmander"]
print("---3.如果数组中有多个相同的元素,获取最后一个的索引,myArray3.lastIndexOf(charmander):\(String(describing: myArray3.lastIndex(of: "charmander")))")
var myArray4 = ["charmander","bulbasaur","squirtle"]
myArray4.removeFirst("charmander")
print("---4.删除指定元素,myArray4:\(myArray4)")
let myArray5 = ["charmander","bulbasaur","squirtle"]
print("---5.是否包含某个元素,myArray5.containsInstanceOf:\(myArray5.contains("charmander"))")
print("---6.是否包含另一个数组中的所有元素,myArray5.containsInstanceOf(1):\(myArray5.containsType(of: Int.self))")
let myArray6 = ["charmander","bulbasaur","squirtle"]
print("---7.是否包含另一个数组中的元素,containsArray([charmander,bulbasaur]):\(myArray6.contains(["charmander","bulbasaur"]))")
print("myArray6.containsArray([string]):\(myArray6.contains(["string"]))")
var myArray7 = ["charmander","bulbasaur","squirtle",1,2,3] as [Any]
myArray7.shuffle()
print("---8.乱序, myArray7:\(myArray7)")
var myArray8 = ["charmander","bulbasaur","squirtle"]
myArray8.insertFirst("snorlax")
print("---9.在开头插入一个元素,myArray8:\(myArray8)")
let myArray9 = ["charmander","bulbasaur","squirtle"]
print("---10.俩个数组的 交集, myArray9.intersection:\(myArray9.intersection(["charmander","pikachu","bulbasaur"]))")
print("---11.俩个数组的 并集,myArray9.union:\(myArray9.union(["charmander","pikachu"]))")
let myArray10 = ["charmander","bulbasaur","squirtle","pikachu"]
print("---12.俩个数组的 差集(互不拥有的元素), myArray10.difference:\(myArray10.difference(["charmander","bulbasaur"]))")
}
}