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.
print(x);
print x
console.log(x);
class X<T> {
T x;
X(T x) { this.x = x; }
public String toString() {
var s = new StringBuilder();
var f = new Formatter(s);
f.format("%s", getClass().getName());
f.format("<%s>", x.getClass().getName());
f.format("@%x", hashCode());
f.flush();
return s.toString();
}
}
X<?> x = new X<>(123);
out.println(x);
writeln(x.T);
package Point {
my $_data = {};
sub new {
my $class = shift;
$_data = { @_ };
bless $_data, $class;
};
use overload '""' => sub { shift->_stringify() };
sub _stringify {
my $self = shift;
return sprintf 'A point at (%d, %d)', $self->{x}, $self->{y};
}
}
my $p = Point->new(x => 5, y => 10);
print $p;
print(x)
puts x
println!("{:?}", x);
Debug.Print x