Is there any way to match just on generic type passed in function? I'd like to do:
def getValue[T](cursor: Cursor, columnName: String): T = {
val index = cursor.getColumnIndex(columnName)
T match {
case String => cursor.getString(index)
case Int => cursor.getInteger(index)
}
I thought about something like classOf
or typeOf
, but none of them is acceptable for just types, but objects.
My idea was also to create some object of type T
and then check its type, but I think there can be a better solution.