> On Jan 10, 2018, at 10:10 AM, Riley Testut <[email protected]> wrote: > > On Jan 9, 2018, at 10:02 PM, Chris Lattner via swift-evolution > <[email protected] <mailto:[email protected]>> 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
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
