oops with swift code example
Example: oops with swift
class Maths {//1 //2 let a: Int! let b: Int! private var result: Int? //3 init(a: Int,b: Int) { self.a = a self.b = b } //4 func add() { result = a + b } //5 func displayResult() { print("Result - \(result)") }}let calculation = Maths(a: 2, b: 3)calculation.add()calculation.displayResult()