Start the shell with erl; each expression ends with a period: 1 + 2.. Quit with q()..
Erlang · Lesson 1 · On the house
Running Erlang and printing
The erl shell, escript files, io:format directives, and ending expressions with periods. Lesson 1 is free — on the house.
Lessons · Erlang · Lesson 1 of 10 · On the house
Running Erlang and printing
The erl shell, escript files, io:format directives, and ending expressions with periods.

An escript is a runnable file whose entry point is main(Args) ->. Run it with escript hello.erl.
io:format("~p~n", [Term]) prints: ~p pretty-prints any term, ~s prints a string, ~w writes raw, ~n is a newline. Arguments always go in a list.
Punctuation matters: , separates expressions in a body, ; separates clauses, . ends a function.
Comments start with %.
io:format
main(_) ->
io:format("hello, ~s~n", ["erlang"]),
io:format("~p ~p~n", [42, {ok, [1, 2]}]),
io:format("~w~n", ["ab"]),
io:format("~5.2f|~n", [3.14159]),
io:format("~-6s|~n", ["hi"]).
Quiz
Quiz
Quiz
Quiz
Check
Match the still for: Running Erlang and printing.
Open-book: the answers are on this page. Pass every quiz and check (5) to mark the lesson done. This visit: 0/5.