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

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"
主站蜘蛛池模板: 洛宁县| 汉川市| 陈巴尔虎旗| 泗阳县| 稷山县| 霍邱县| 云浮市| 鹤峰县| 万源市| 亳州市| 滦南县| 喀什市| 新邵县| 通化市| 开化县| 株洲市| 滦南县| 卢湾区| 西宁市| 巴东县| 南雄市| 正镶白旗| 循化| 曲阳县| 桐柏县| 伊金霍洛旗| 烟台市| 钦州市| 吴忠市| 阿克苏市| 九龙县| 铁岭市| 湄潭县| 会同县| 孙吴县| 芦溪县| 交口县| 大关县| 施秉县| 漳浦县| 阳江市|