官术网_书友最值得收藏!

Subscripts

Subscripts are shortcuts to access the member elements of a collection, list, sequence, or any custom type that implement subscripts. Consider the following example:

struct TimesTable { 
let multiplier: Int
subscript(index: Int) ->Int {
return multiplier * index
}
}

let fiveTimesTable = TimesTable(multiplier: 5)
print("six times five is \(fiveTimesTable[6])")
// prints "six times five is 30"
主站蜘蛛池模板: 台北市| 肃南| 河西区| 南丰县| 西和县| 枣阳市| 涿州市| 葵青区| 调兵山市| 垫江县| 横峰县| 法库县| 安西县| 温宿县| 化州市| 安新县| 大方县| 林芝县| 新邵县| 邳州市| 汤阴县| 陇西县| 长丰县| 台山市| 长寿区| 德昌县| 永善县| 惠来县| 辰溪县| 修武县| 浮梁县| 南和县| 南溪县| 繁峙县| 平遥县| 秭归县| 新邵县| 阳原县| 焦作市| 上林县| 桦南县|