debug { D.print("a thing i need to debug")};
The above gets taken out of your code by the compiler at build time if you use the release flag. The Motoko team has the flags, so I’ll let them document, but this enables a much better local development debug pattern like:
let debug_channel = {
feature1 = true;
feature2 = false;
};
...later
public shared func test() : async Bool{
debug{ if(debug_channel.feature1){D.print("my function was called");};
};
Also only for local debugging because it will trap, but a godsend for testing:
let #ok(myresult) = await myservice.function(); //throws if not an #ok variant
let something = myresult.without_unwrapping;
Again…don’t use this in your main actor code, but if you are writing motoko tests, this is going to save me hundreds of lines of code.