Can we have default values for method's arguments on protocol extensions?
If so can we override those methods on structs that implement that protocol?
I'm doing it, but I'm having unexpected results. Why is that? Thanks!
import Foundation
protocol Datasource {
func getLetter(_ uppercased: Bool) -> String
}
extension Datasource {
func getLetter(_ uppercased: Bool = true) -> String {
return uppercased ? "B" : "b"
}
}
struct ADatasource: Datasource {
func getLetter(_ uppercased: Bool = true) -> String {
return uppercased ? "A" : "a"
}
}
let datasource: Datasource = ADatasource()
datasource.getLetter(true) // returns "A"
datasource.getLetter() // returns "B"