why does io:get_line return "\n" in erlang shell? -


when using io:getline("prompt") in erlang shell , function returns return value of "\n"

io:get_line("prompt").  prompt "\n" 

but suggested in thread doing following reads standard_io correctly.

spawn(fun() -> timer:sleep(100),io:get_line("prompt") end).  

waits user input , reads standard io (shell). mentioned race condition . can tell me why , how possible read value erlang shell ?

io:get_line/1 , io:get_line/2 returns data \n every time.

get_line(prompt) -> data | server_no_data()

where:

data

the characters in line terminated lf (or end of file). if io device supports unicode, data may represent codepoints larger 255 (the latin1 range). if i/o server set deliver binaries, encoded in utf-8 (regardless of if io device supports unicode or not).

in first case got \n, , try result of io:get_line in second case:

spawn(fun() ->        timer:sleep(100),        result = io:get_line("prompt"),        io:format("result: ~p~n", [result])  end). 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -