​Quick is just a strong and spontaneous coding language for macOS, iOS, watchOS and tvOS....

Page 207

Swift

Inside Sum Block:(100, 200) Inside Diff Block: (200, 100)

Methods New instance methods and type methods can be added further to the subclass with the help of extensions. extension Int { func topics(summation: () -> ()) { for _ in 0..<self { summation() } } }

4.topics({ println("Inside Extensions Block") })

3.topics({ println("Inside Type Casting Block") }) When we run the above program using playground, we get the following result: Inside Extensions Block Inside Extensions Block Inside Extensions Block Inside Extensions Block Inside Type Casting Block Inside Type Casting Block Inside Type Casting Block topics() function takes argument of type '(summation: () -> ())' to indicate the function does not take any arguments and it won't return any values. To call that function multiple number of times, for block is initialized and call to the method with topic() is initialized.

195


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