​Quick is a strong and instinctive development language for macOS, iOS, watchOS and tvOS....

Page 136

Swift

} let division = subexample(decrementer: 100)

println("The number is divisible by \(division[9]) times") println("The number is divisible by \(division[2]) times") println("The number is divisible by \(division[3]) times") println("The number is divisible by \(division[5]) times") println("The number is divisible by \(division[7]) times") When we run the above program using playground, we get the following result: The number is divisible by 11 times The number is divisible by 50 times The number is divisible by 33 times The number is divisible by 20 times The number is divisible by 14 times

Example2 class daysofaweek { private var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "saturday"] subscript(index: Int) -> String { get { return days[index] } set(newValue) { self.days[index] = newValue } } } var p = daysofaweek()

println(p[0]) println(p[1]) println(p[2]) println(p[3]) 124


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.