Mix.install([
{:youtube, github: "brooklinjazz/youtube"},
{:hidden_cell, github: "brooklinjazz/hidden_cell"},
{:tested_cell, github: "brooklinjazz/tested_cell"},
{:utils, path: "#{__DIR__}/../utils"}
])
Ensure you type the ea
keyboard shortcut to evaluate all Elixir cells before starting. Alternatively you can evaluate the Elixir cells as you read.
When building command line applications, we can use the IO module for retrieving user input and displaying output in the command line.
We've can use IO.inspect/2 and IO.puts/2 for displaying information in the command line.
We can also use IO.gets/2 to retrieve input from the user.
iex> input = IO.gets("Give me some input: ")
Give me some input: sure!
"sure!\n"
iex> input
"sure!\n"
Keep in mind, this will work in a Mix project, or the IEx shell, but will fail with an :enotsup
(error not supported) error when we run it from Livebook.
IO.gets("I will fail!")
That's because there is no command line or other device to retrieve user input from.
Run IO.gets/2 in the command line from the IEx shell and bind the return value to an input
variable.
iex> input = IO.gets("Give me some input: ")
Run the following in your command line from the beta_curriculum folder to track and save your progress in a Git commit.
$ git add .
$ git commit -m "finish io section"
Previous | Next |
---|---|
Mix | Games Setup |