Which overloaded function is selected [closed]

1 day ago 1
ARTICLE AD BOX

Given the following code:

func f(a: Int, _ b: Int = 0) { print("1 \(a + b)") } func f(a: Int) { print("2 \(a)") } f(a: 42)

It prints out "2 42".
Two questions:

why does it select second function?

how do I force it to call the first function?

Nick's user avatar

Read Entire Article