I know it is possible to pass class type to a function in swift:
func setGeneric(type: T.Type){ } setGeneric(Int.self)
But how we can
You can return any type you want.
func getTypeOfInt() -> Int.Type { return Int.self } func getTypeOfBool() -> Bool.Type { return Bool.self }
If the type is not determined from arguments or if the return is constant, there is no need to introduce a generic T type.
T