https://kotlinlang.org logo
Title
p

pavlospt

03/17/2017, 2:31 PM
And what I want is to just call that method on something like:
override fun <T> getFoo() : T? { return fromBytes(byteArray) }
o

okkero

03/17/2017, 2:46 PM
In this case, you would need a reifiable reference to T
p

pavlospt

03/17/2017, 2:47 PM
True, but I cannot have one, right?
o

okkero

03/17/2017, 2:47 PM
Maybe you could pass a
KClass<T>
though the constructor of the enclosing class?
p

pavlospt

03/17/2017, 2:49 PM
Hmm I am not following 😕
o

okkero

03/17/2017, 2:54 PM
getFoo is in a class, right?
p

pavlospt

03/17/2017, 3:05 PM
yeap
o

okkero

03/17/2017, 3:43 PM
then the common Java way of doing it has been to add an extra parameter to the constructor
hold on, I just realised T is not part of the class, but of the function
hm
p

pavlospt

03/17/2017, 3:48 PM
Hehe that’s what is been killing me for some hours now 😞
Unfortunately I ended up providing the Class<T> through the method..