Logo

Programming-Idioms

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.
New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
(type x)
#include <typeinfo>
std::cout<<typeid(x).name();
System.Console.WriteLine( x.GetType() );
import std.stdio: writeln;
writeln(typeid(x));
print(x.runtimeType);
[{_, type} | _] = IEx.Info.info(x)
type
fmt.Printf("%T", x)
import "reflect"
fmt.Println(reflect.TypeOf(x))
import Data.Dynamic
print (dynTypeRep (toDyn x))
console.log (x == null ? x + '' : x.constructor.name);
console.log(typeof x);
System.out.println(((Object)x).getClass().getName());
import java.lang.reflect.Modifier;
System.out.print(x.getClass().getName());
if(x.getClass().getModifiers() == Modifier.STATIC) {
	System.out.println(" is static");
} else {
	System.out.println(" is dynamic");
}
println(x::class.simpleName)
(describe x)
print(type(x))
echo is_object($x) ? get_class($x) : gettype($x);
print ref($x)||"SCALAR", "\n";
print(x.__class__)
print(type(x))
puts x.class
#![feature(core_intrinsics)]
fn type_of<T>(_: &T) -> &'static str {
    std::intrinsics::type_name::<T>()
}

println!("{}", type_of(&x));