Any

    2022 WWDC Design protocol interfaces in Swift

    Understand type eraure: associated type이 있는 protocol이 existential any type과 어떻게 상호 작용하는지 설명. Hide implementation details: interface와 implementation을 분리해서 캡슐화하기 위해 opaque type을 사용하는 방법에 대해 설명. Identify type releationships: protocol에서 same-type requirements가 concrete type의 여러가지 다른 sets간의 관계를 모델링하는 방법에 대해 설명. Understand type eraure protocol Animal { associatedtype CommodityType: Food func produce()..

    Existential any in Swift explained with code examples(번역)

    원문: https://www.avanderlee.com/swift/existential-any/ Existential any in Swift explained with code examples Existentials in Swift are defined using the any keyword and provide dynamic types, but also come with performance impact you should know. www.avanderlee.com Existential any를 사용하면 type 앞에 any 키워드를 붙여 existential types를 정의할 수 있다. 간단히 말해 existential는 “any type이지만 protocol ’something’을 준수한다.”를..

    Swift Opaque Types(번역)

    Swift Opaque Types(번역)

    원문: Some keyword in Swift: Opaque types explained with code examples Some keyword in Swift: Opaque types explained with code examples The some keyword in Swift allows you to define opaque parameter and return types. Expose only minimum APIs without losing performance. www.avanderlee.com Opaque Type Concrete Type을 정의하지 않고 예상되는 반환 타입을 설명할 수 있다. 이 같은 것은 SwiftUI body에 사용되는 것을 볼 수 있다. var body: some ..