Page 129


class division { var count: Int = 0 func incrementBy(no1: Int, no2: Int) { count = no1 / no2 println(count) } }

let counter = division() counter.incrementBy(1800, no2: 3) counter.incrementBy(1600, no2: 5) counter.incrementBy(11000, no2: 3) When we run the above program using playground, we get the following result: 600 320 3666

External Parameter Name with # and _ Symbol Even though Swift methods provide first parameter names for local declarations, the user has the provision to modify the parameter names from local to global declarations. This can be done by prefixing '#' symbol with the first parameter name. By doing so, the first parameter can be accessed globally throughout the modules. When the user needs to access the subsequent parameter names with an external name, the methods name is overridden with the help of '_' symbol. class multiplication { var count: Int = 0 func incrementBy(#no1: Int, no2: Int) { count = no1 * no2 println(count) } }

let counter = multiplication() counter.incrementBy(no1: 800, no2: 3) 117

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