Problem Statement
Differentiate between using `associatedtype` in a protocol and using a generic placeholder in a generic type. When would you choose each?
Explanation
An `associatedtype` in a protocol defines a placeholder type that the conforming type will specify. It allows the protocol to be generic over some type but hides the actual type until implementation. A generic placeholder (like `T`) in a generic type or function is defined when that code is declared. /n/n Use `associatedtype` when you want your protocol to work with one or more unspecified types but allow different conforming types to specify different underlying types. Use generics when defining functions or types that are parameterised by type. /n/n For example `protocol Container { associatedtype Item; func append(_ item: Item) }` vs `struct Stack<T> { var items: [T]; mutating func push(_ item: T) { items.append(item) } }`. Understanding when to use each demonstrates depth of Swift's type system.