Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 697 Bytes

File metadata and controls

31 lines (23 loc) · 697 Bytes

toString

All Objects have a toString method.

This is intended to be a suitable representation for debugging, although one may choose to favor different concerns.

For built-in classes the result of their toString method is likely what you'd expect.

~class Apple {}
~void main() {
Object o = "123";

// If its already a String, toString() doesn't
// have to do much work
IO.println(o.toString());

o = 123;
// Integers, Longs, etc. all have a representation
// which looks the same as they do in literal form.
IO.println(o.toString());

o = new Apple();
// And custom classes will, by default, just have the
// class name followed by gibberish
IO.println(o.toString());
~}