79276779

Date: 2024-12-12 22:39:02
Score: 0.5
Natty:
Report link

I found a solution where I am able to cast it in a bit more elegant way.

val map = if (value.all { it.key is String && it.value is Any }) {
    value.cast<Map<String, Any>>()
} else {
    throw IllegalArgumentException("Illegal argument exception for unsupported map type")
}
...
private inline fun <reified T> Any.cast(): T = this as T

and in similar way with the List<*>.

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Reddi