Swift Tutorial - Tutorialspoint

(backadmin) #1
studdet.marks = 98
studdet.markssecured()

println(studdet.marks)
println(studdet.result)
println(studdet.present)
println(studdet.subject)
println(studdet.stname)

When we run the above program using playground, we get the following result:


98


true
false
Swift Protocols
Swift

Mutating Method Requirements


protocol daysofaweek {
mutating func print()
}

enum days: daysofaweek {
case sun, mon, tue, wed, thurs, fri, sat
mutating func print() {
switch self {
case sun:
self = sun
println("Sunday")
case mon:
self = mon
println("Monday")
case tue:
self = tue
println("Tuesday")
case wed:
Free download pdf