Swift is really a strong and instinctive coding language for macOS, iOS, watchOS and tvOS....

Page 221

Swift

}

class Player { var stmark: result!

init(stmark: result) { self.stmark = stmark }

func print(target: classa) { stmark.print(target) } }

var marks = Player(stmark: student2()) var marksec = student()

marks.print(marksec) marks.print(marksec) marks.print(marksec) marks.stmark = classb() marks.print(marksec) marks.print(marksec) marks.print(marksec) When we run the above program using playground, we get the following result: Student attempted 1 times to pass Student attempted 1 times to pass Student attempted 1 times to pass Student attempted 5 times to pass Student attempted 5 times to pass Student is absent for exam Student attempted 5 times to pass Student is absent for exam

209


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