문제

I would like to know if there is any function in Erlang for writing

io:format("An output line~n").

in the standard output, without having to write ~n every time, i.e. an equivalent to Java's

System.out.println("An output line");

I mean an already existing Erlang function. I know if it doesn't exist what I should do is creating my own function for that:

write_output(Text) ->
    io:format("~p~n", [Text]).
도움이 되었습니까?

해결책

No, there is not, but writing one yourself is pretty simple:

myf(FS, Opts) ->
    io:format(FS, Opts),
    io:nl().

다른 팁

Today, IODevice command is optional for io operations.

io:write(["~cmd1~cmd2",]T) 

format, read & write can all be used in one line. as..

io:format(T);
% or
io:write(T);

but if there is a need for the line feed, the author's original code is more accurate

io:format("~p~n",[Number])

if building a function other built-in functions may be used to do the same

io:format(string:concat(integer_to_list(Number),"\n"))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top