[swift-evolution] [Proposal] Revamp the playground quicklook APIs

Chris Lattner clattner at nondot.org
Wed Jan 10 14:17:39 CST 2018


> On Jan 10, 2018, at 10:10 AM, Riley Testut <rileytestut at gmail.com> wrote:
> 
> On Jan 9, 2018, at 10:02 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at 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?

-Chris


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20180110/3fc282b8/attachment.html>


More information about the swift-evolution mailing list