subscript(index: Int) -> Int {
get {
// Return an appropriate subscript value here.
}
set(newValue) {
// Perform a suitable setting action here.
}
}
struct Age {
let multiplier: Int
subscript(index: Int) -> Int {
return multiplier * index
}
}
let greenAge = Age(multiplier: 12)
print("greenAge's converted age is \(greenAge[5])")
// Prints "greenAge's converted age is 60"
Subscript란?