Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

Modifying Value Types from Method Swift

struct Employee {
  var salary = 0
  
  // define mutating function
  mutating func salaryIncrement(increase: Int) {

  // modify salary property  
  salary = salary + increase
  print("Increased Salary:",salary)
  }
}

var employee1 = Employee()
employee1.salary = 20000
employee1.salaryIncrement(increase: 5000)
 
PREVIOUS NEXT
Tagged: #Modifying #Value #Types #Method #Swift
ADD COMMENT
Topic
Name
1+2 =