Type detection: Difference between revisions
Added solution for D
(Added C implementation.) |
(Added solution for D) |
||
Line 102:
3 is a hexadecimal digit
</pre>
=={{header|D}}==
<lang D>import std.stdio;
auto typeString(T)(T _) {
return T.stringof;
}
class C {}
struct S {}
void main() {
writeln(typeString(1));
writeln(typeString(1L));
writeln(typeString(1.0f));
writeln(typeString(1.0));
writeln(typeString('c'));
writeln(typeString("string"));
writeln(typeString(new C()));
writeln(typeString(S()));
writeln(typeString(null));
}</lang>
{{out}}
<pre>int
long
float
double
char
string
C
S
typeof(null)</pre>
== {{header|J}} ==
|