Methods with optional parameter values in Swift
Forums:
func sayGoodby(message: String = "Goodby!") {
print(message)
}
sayGoodby()
//prints "Goodby!"
sayGoodby("see you")
//prints "see you"
- Log in to post comments
func sayGoodby(message: String = "Goodby!") {
print(message)
}
sayGoodby()
//prints "Goodby!"
sayGoodby("see you")
//prints "see you"