As
1. The compiler checks the legality of the type conversion; static
Let cell = Collectionview.dequeuereusablecell (Withreuseidentifier:shoppinglist[indexpath.section], For:indexpath as Indexpath)
Let k = cell as Indexpath
Cannot convert value of type ' Uicollectionviewcell ' to type ' indexpath ' in coercion
2, with switch: type detection
as! As?
Type dynamic transformation;
Convert any type to a specific type, type system check.
When a type is a function parameter, it belongs to the dynamic type;
Type systems and compilers are closely related.
When initializing an instance with a type, the compiler requires that the type qualification must be static, as opposed to a function call.
Therefore, the type parameter that is passed as a type must be qualified for initialization of the instance.
(Type as! Hmloginmodel.type). Init ()
Extension Observabletype where E = = Response {
Public Func mapmodel<t:handyjson> (_ Type:t.type), observable<t> {
Return FLATMAP {response-observable<t> in
(Type as! Hmloginmodel.type). Init ()
Return Observable.just (Response.mapmodel (t.self))
}
}
}
Swift as, as!, as? Differentiate between t.type and dynamic types