Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

Swift n Parameter with Default Values

func addNumbers( a: Int = 7,  b: Int = 8) {
  var sum = a + b
  print("Sum:", sum)
}

// function call with two arguments
addNumbers(a: 2, b: 3)

// function call with one argument
addNumbers(a: 2)

// function call with no arguments
addNumbers()
 
PREVIOUS NEXT
Tagged: #Swift #Parameter #Default #Values
ADD COMMENT
Topic
Name
4+6 =