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

Page 236

Swift call sum() and its values are printed thereby eliminating return values. To make the function's return type as private, declare the function's overall access level with the private modifier. private func sum(a: Int, b: Int) { let a = a + b let b = a - b println(a, b) }

sum(20, 10) sum(40,10) sum(24,6) When we run the above program using playground, we get the following result: (30, 20) (50, 40) (30, 24)

Access Control for Enumeration types public enum Student{ case Name(String) case Mark(Int,Int,Int) } var studDetails = Student.Name("Swift") var studMarks = Student.Mark(98,97,95) switch studMarks { case .Name(let studName): println("Student name is: \(studName).") case .Mark(let Mark1, let Mark2, let Mark3): println("Student Marks are: \(Mark1),\(Mark2),\(Mark3).") default: println("Nothing") } When we run the above program using playground, we get the following result: Student Marks are: 98,97,95 224


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