https://kotlinlang.org logo
Title
u

user

07/08/2022, 9:11 AM
Generic "checkType" function with args as parameter, but I don't know how to make it able to the value type according to attached parameters Example input: checkType(10) output: "Yes! it's Integer" Here are some mandatory value types: Integer String Boolean Double List Map fun checkType(args: T): String { return "" } fun main() { println( """ '[10, 9, 8 , 6]' is List? ${checkType(listOf(10, 9, 8, 6))} 'This is Koltin' is String? ${checkType("This is Kotlin")} 'True' is Boolean? ${checkType(true)} '10.01' is List? ${checkType(10.01)} """.trimIndent() ) }