I'm trying to print an object in Toit with print o
, but I'm only getting
When printing an object it only shows "an instance with class-id 12".
Here is a small example:
class A:
main:
o := A
print o
which prints:
an instance with class-id 42
The default stringify
method of Object
does not include the name of the class. This is to save space. However, an unstripped snapshot does.
If you first compile your program to a snapshot (toit.compile -w app.snapshot app.toit
) then you can use toitp
to inspect the snapshot. For example toitp --classes app.snapshot
lists all classes with their ids.
The toit.compile
executable is located in the bin
folder of the SDK, and the toitp
program is located in the tools
folder of the SDK.
You can download the SDK either from https://github.com/toitlang/toit, or, if you use Jaguar, it is also cached in ~/.cache/jaguar/sdk
(and a similar path on Windows).