On Fri, Jul 8, 2016 at 10:34 AM, Roth Michaels via swift-users < [email protected]> wrote:
> On Fri, Jul 08 2016 at 11:11:04 AM, Nate Birkholz via swift-users < > [email protected]> wrote: > > This gives an error, expecting a colon (:) after object on every case. > > > > I wanted to be sure I wasn't missing something in my syntax (nor some > > obvious-to-others reason this isn't supported) before going to swift > > evolution. > > There is a bug filed to improve this error message: > https://bugs.swift.org/browse/SR-2022 > > On Fri, Jul 08 2016 at 11:15:48 AM, Dan Loewenherz via swift-users < > [email protected]> wrote: > > To my knowledge, you can’t do exactly what you’re trying to do > > Here is how: > > ```Swift > > for object in objects { > switch object { > case let object as Subclass1: > doSomethingWith(object) > case let object as Subclass2: > doSomethingWith(object) > case let object as Subclass3: > doSomethingWith(object) > default: > break > } > } > Beautiful, thanks Roth! This is much nicer. :) Dan
_______________________________________________ swift-users mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-users
