Motoko QoL trick

We still don’t have string interpolation, but you can have something similar by debug_show-ing ad-hoc records and resorting to field punning:

let some_binding = ...;
let other = ...;
debug {
   Debug.print(debug_show {some_binding; other})
}

will nicely output { other = ...; some_binding = ... } to the console.

Enjoy!

PS: I found this in the moc test suite, btw. Not sure who came up with it first.

2 Likes

Claudio, it seems, according to git log -G: