I am novice in Swift programming. I am not able to understand following code. In following code to call
- incrementBy method: I must have to type numberOfTimes in second argument. But,
sampleFunc method: I must not have to type lastName in second argument.
class Counter { var count: Int = 0 func incrementBy(amount: Int, numberOfTimes : Int) { count += amount * numberOfTimes } } var counter = Counter() counter.incrementBy(1, numberOfTimes : 3) print(counter.count) func sampleFunc(firstName : String, lastName : String){ print("Hello \(firstName) \(lastName)") } sampleFunc("Abel", "Rosnoski")
Why is there subtle difference? Please explain.