Problem Statement
How do protocol extensions provide default implementations in Swift, and what are some pitfalls to be aware of?
Explanation
Protocol extensions allow you to provide an implementation of protocol methods and properties that conforming types can use without implementing themselves. This encourages code reuse and cleaner design. /n/n However you must be aware of pitfalls: when a protocol requirement is defined but the default implementation is in an extension, if you call the method via a protocol-typed reference you might get the default implementation rather than the overridden one due to static dispatch. Also overuse of default implementations may blur the line between abstraction and concrete behaviour. /n/n Understanding dispatch rules (static vs dynamic) and when protocol extensions lead to unexpected behaviour is key for interviews.