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

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"
主站蜘蛛池模板: 荣成市| 子长县| 临武县| 连南| 宝鸡市| 万载县| 交口县| 怀仁县| 大姚县| 瓦房店市| 甘泉县| 辉南县| 葵青区| 辉南县| 滁州市| 永昌县| 棋牌| 昌乐县| 长白| 七台河市| 汪清县| 自治县| 友谊县| 禄丰县| 河池市| 临清市| 西华县| 曲靖市| 淮滨县| 金堂县| 宝丰县| 堆龙德庆县| 巴青县| 武城县| 古交市| 昌吉市| 霍城县| 华宁县| 平武县| 平湖市| 陵川县|