I have a SimpleListProperty<T>, how can I do...
# getting-started
j
I have a SimpleListProperty<T>, how can I do a when (t) { is T -> todo() } how to extract the Type contained in the list property?
j
Where are you trying to write this
when
? Could you give a bit more context? How do you get the instance of
SimpleListProperty<T>
and what is
t
here? In general, if this class itself doesn't give access to the class of
T
, you can't. It is erased, so at runtime all you see is
SimpleListProperty
, not
SimpleListProperty<String>
. However, depending on how/where you want to use this information, using
reified
types may enable you to still get the information.
j
Copy code
fun <T: Entity<T>> createLog(
    filename: String,
    logType: LogType,
    entityList: SimpleListProperty<T>,
    projectNum: SimpleStringProperty,
    projectName: SimpleStringProperty
I pass it to the function, T is an Entity<T> from ktorm, they are database entires.
inside the function I want to know T so I call another function that will process the entries based upon the type of entry they are
actually I see what I can do now, I can just use logType. I'm dumb
rubber duck 1
👌 1