> On Jan 10, 2018, at 10:10 AM, Riley Testut <rileytes...@gmail.com> wrote:
> On Jan 9, 2018, at 10:02 PM, Chris Lattner via swift-evolution 
> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>> What is the use-case for a type conforming to this protocol but returning 
>> nil?  If there is a use case for that, why not have such an implementation 
>> return “self” instead?
> I assumed it could be used if a type’s playground representation was 
> variable. For instance:
> enum MyUnion
> {
>     case string(String)
>     case image(UIImage)
>     case none
> }
> In its implementation of CustomPlaygroundRepresentable, it could return a 
> string if case string, an image if case image, or return nil if case none to 
> just do whatever is the default for enum values. 
> Admittedly the above is a very contrived example, but I do think it is 
> important to allow types to opt-out.

You should just be able to return ‘self' in that case?


swift-evolution mailing list

Reply via email to