Logo

Programming-Idioms

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

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.

(type x)
#include <typeinfo>
std::cout<<typeid(x).name();

The name of a type is implementation defined and is not neccessarily the same, even between different runs of the program.

Also many implementations allow the availability of type info to be switched off.

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