bbousquet
(Benoît Bousquet)
January 22, 2019, 9:27pm
1
Is there such a thing?
I have a function which returns a type, as follows:
public class func classForType(_ type: Int) -> BaseClass.Type? {
var deviceType: BaseClass.Type? = nil
switch type {
case 1:
deviceType = Subclass1.self
case 2:
deviceType = Subclass2.self
// ...
}
return deviceType
}
mh
(marc hoffman)
January 23, 2019, 2:04pm
2
I always get confused by that .Type
actually is supposed to represent. But afaik, there’s .Type
on the class name, .dynamicType
on distances, both are the same as the all-languages typeOf()
function.
bbousquet
(Benoît Bousquet)
January 23, 2019, 2:45pm
3
mh:
I always get confused by that .Type
actually is supposed to represent. But afaik, there’s .Type
on the class name, .dynamicType
on distances, both are the same as the all-languages typeOf()
function.
My original post wasn’t clear: the code snippet works in Swift but does not in Silver. It’s as if Silver didn’t know what .Type
was.
mh
(marc hoffman)
January 23, 2019, 2:56pm
4
Hm, ok. what platform, Java?
bbousquet
(Benoît Bousquet)
January 23, 2019, 2:59pm
5
Didn’t work in Toffee (I’d like to use it for both Toffee and Cooper, down the line).
Thanks, logged as bugs://81802