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.
- Clojure
- C++
- C#
- D
- Dart
- Elixir
- Go
- Go
- Haskell
- JS
- JS
- Java
- Java
- Kotlin
- Lisp
- Lua
- PHP
- Pascal
- Perl
- Python
- Python
- Ruby
- Rust
(type x)
[{_, type} | _] = IEx.Info.info(x)
type
print (dynTypeRep (toDyn x))
Haskell is statically typed with type erasure. But all types member of the Typeable type class can be made into dynamic types by toDyn. We print the type rep which prints the name of the dynamic type.
console.log (x == null ? x + '' : x.constructor.name);
Gives you the name of the function used to build xโit always works due to the "everything is an object" principle.
console.log(typeof x);
In most cases you'll get "object" unless you put in a primitive or function.
(describe x)
the result is different, depending on your specific implementation of lisp.
print(type(x))
This prints the dynamic type of x
echo is_object($x) ? get_class($x) : gettype($x);
$x is dynamic type
{$mode objfpc}{$H+}
{$ModeSwitch ImplicitFunctionSpecialization }
generic procedure PrintTypeOfX<T>(const X: T);
var
tk: TTypeKind;
begin
tk := System.GetTypeKind(X);
writeln(tk);
end;
Requires fpc >= 3.3.1.
print ref($x)||"SCALAR", "\n";
Example:
my $s = "foo";
my @a = (1,2);
my %h = {foo=>1, bar=>2};
my $o = bless {}, 'OBJECT';
print ref($_)||"SCALAR", "\n" for $s, \@a, \%h, $o;
Output:
SCALAR
ARRAY
HASH
OBJECT
my $s = "foo";
my @a = (1,2);
my %h = {foo=>1, bar=>2};
my $o = bless {}, 'OBJECT';
print ref($_)||"SCALAR", "\n" for $s, \@a, \%h, $o;
Output:
SCALAR
ARRAY
HASH
OBJECT
print(x.__class__)
puts x.class