Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Kotlin

Idiom #94 Print the type of a variable

Print the name of the type of x. Explain if it is a static type or dynamic type.

This may not make sense in all languages.

println(x::class.simpleName)

Static type. Not really another way to do this in Kotlin.
(type x)

New implementation...
< >
programming-idioms.org