找到你要的答案

Q:String template with erlang

Q:Erlang字符串模板

With language like JS it's really easy to write something like:

var a = 5;
console.log(a + ' times\n');

how can I write the same code with erlang?

语言像JS很容易写东西一样:

var a = 5;
console.log(a + ' times\n');

我怎么能用Erlang编写相同的代码?

answer1: 回答1:

If your question is about stringification of any Erlang term, there is ~p in io:format/2,3 function.

A = 5, io:format("~p times~n", [A]).

If you are interested in debugging output, there is also erlang:display/1 function. It works like io:format("~p~n", [X]), true..

如果你的问题是关于任何Erlang项字符串化所带来的,有~ P IO:格式/ 2功能。

A = 5, io:format("~p times~n", [A]).

如果你在调试输出感兴趣,还有二郎:显示/ 1功能。它的工作原理,如IO格式(“P N”,[ x ]),真的..

erlang