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