Methods without any return value in Swift
Forums:
class Counter {
var count = 0
func incBy(value: Int) {
count += value
}
func incBy(value: Int, amount: Int) {
count += value * amount
}
}
let counter = Counter()
counter.incBy(1)
//Counter.count is 1
counter.incBy(2, amount: 5)
//Counter.count is 11
- Log in to post comments