> On Feb 9, 2017, at 13:31 , Saagar Jha <[email protected]> wrote:
>
> for item in someOptionalCollection ?? [] {
> item.doSomething()
> }
>
Thanks, this is probably the closest. Sadly I can't seem to test downcasting
because Playgrounds just stop working, with no feedback, for this code:
class Foo
{
init(_ inVal: String) { self.name = inVal }
var name: String
var desc: String { get { return "Foo \(name)" } }
}
let f = Foo("foo")
class Bar : Foo
{
var desc: { return "Bar \(name)" }
}
let stuff: [Foo]?// = [Bar("foo"), Bar("bar"), Bar("baz")]
for item in (stuff as? [Bar]) ?? []
{
}
--
Rick Mann
[email protected]
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users