Ori
November 27, 2019, 11:14pm
1
If you want to print output to the terminal, for now you can use debugPrint() along with debug_show():
let a: Nat = 10;
debugPrint(debug_show(a));
This outputs to the terminal that’s running dfx start (note this might be a separate window if you’re not using the --background flag).
6 Likes
Thanks for sharing the Syntax Ori.
2 Likes
good hint! did anyone actually make the
print function work?
1 Like
yep it works. Have a look on the repo i posted yesterday, there are a few debug prints in it.
1 Like
Ori
November 28, 2019, 11:03am
5
print() alone isn’t working at the moment, it’s been reported to the team.
If you take a look in Guillaume’s repo you’ll see there are type-specific debug prints like debugPrintNat() too.
Another option is importing prelude and using printLn() (which calls debugPrint internally).
1 Like
I was about to make a post on this but you beat me to it Ori! Nice syntax alternative for those looking to use a similar print functionality.
3 Likes
Ori
January 28, 2020, 11:06pm
7
Please note debugPrint has been moved from the default scope and now requires an import:
import Prim “mo:prim”;
let a: Nat = 10;
Prim.debugPrint(debug_show(a));
1 Like
did you actually manage to import mo:Prim
? didn’t work for me somehow
1 Like
the problem was that i used import Prim „mo:prim.mo“
instead of import Prim „mo:prim“
. that error is kind of weird because all other imports i use have the .mo
suffix and work like a charm? is this because prim
is not part of the stdlib? @claudio
2 Likes
Ori
January 29, 2020, 9:55pm
11
So re this, the .mo extensions in imports will possibly be removed in the next version.
2 Likes
Ori
September 22, 2020, 3:38pm
12
Updating this for recent releases:
import Debug “mo:base/Debug”;
let a: Nat = 10;
Debug.print(debug_show(a));
1 Like