Reputation: 59
I have following function declaration inside class A
typealias Callback<T> = (Result<T>) -> ()
Trying to declare variable in class B
var callbackVariable: A.Callback<T>?
Compiler says: Use of undeclared type 'T'
How to declare variable inside B class?
Upvotes: 0
Views: 72
Reputation: 15218
You need to either:
// 1. Specify a type for T
class B {
var callbackVariable: A.Callback<String>? // Or some other type
}
// 2. Or, make the B class generic as well.
class B<T> {
var callbackVariable: A.Callback<T>?
}
Upvotes: 2