> On Aug 24, 2016, at 8:09 PM, Jaden Geller <[email protected]> wrote: > > Scratch that last message. Determining what's stored in `Any` was Charles's > original goal, and what I said made no sense. This should work: > > func unbridgedCast<T, U>(_ x: T, to: U.Type) -> U? { > guard type(of: x) is U.Type else { return nil } > return x as! U > } > > if let x = unbridgedCast(x, to: String.self) { … }
Hmm, this one actually does seem to work. I had expected that type(of:) would be bridged as well. Thanks; this is definitely better than the Mirror workaround, at least. Charles
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
