> func decodeMe<T>(_ payload:Any) -> T? {
>     if  let dt = T.self as? DecodableFromAny {
>         return type(of: dt).fromAny(payload) as! T
>     } else {
>         return payload as? T
>     }
> }


Auggh! I only thought it worked.  Luckily, I had help.  My 16 year-old son 
looked at this code, and *he* figured it out:  I meant to write
   
>     if  let dt = T.self as? DecodableFromAny {

as

     if  let dt = T.self as? DecodableFromAny.Type {



Now, I swear, it really does work.

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

Reply via email to