Hi,

In the following code, I want to test if x is a `SpecialController`. If it is, 
I want to get the `currentValue` as a `SpecialValue`. How do you do this? If 
not with a cast, then some other technique.

I understand the error, and that SpecialController by itself is not a simple 
type to cast to. But it seems like what I’m saying is logically consistent and 
not that complicated. Is there really no way to *say* it in Swift?

    protocol SpecialController {
        associated type SpecialValueType : SpecialValue
        var currentValue: SpecialValueType? { get }
    }
    ...
    var x: AnyObject = ...
    if let sc = x as? SpecialController {  // does not compile

Rob
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to