源代码:
//
//可变数组的追加,插入,删除,替换.swift
//
// Created by chenzhen on 16/8/1.
// From 大连东软信息学院
// Copyright © 2016年 zhen7216. All rights reserved.
//
import Foundation
var studentList: [String] = ["张三", "李四", "王五"]
print(studentList)
studentList.append("东流")
print(studentList)
studentList += ["刘备","关羽"]
print(studentList)
studentList.insert("张飞",atIndex: studentList.count)
print(studentList)
let removeStudent = studentList.removeAtIndex(0)
print(studentList)
studentList[0] = "诸葛亮"
print(studentList)
运行结果: