diff --git a/lib/elixir/lib/code.ex b/lib/elixir/lib/code.ex index 54c0c092892..f058b4203df 100644 --- a/lib/elixir/lib/code.ex +++ b/lib/elixir/lib/code.ex @@ -185,7 +185,7 @@ defmodule Code do defmodule MyTracer do def trace({:remote_function, _meta, module, name, arity}, env) do - IO.puts "#{env.file}:#{env.line} #{inspect(module)}.#{name}/#{arity}" + IO.puts("#{env.file}:#{env.line} #{inspect(module)}.#{name}/#{arity}") :ok end diff --git a/lib/elixir/lib/task.ex b/lib/elixir/lib/task.ex index 9eba4f452d2..f9bc9702d07 100644 --- a/lib/elixir/lib/task.ex +++ b/lib/elixir/lib/task.ex @@ -842,14 +842,14 @@ defmodule Task do Process.demonitor(ref, [:flush]) {url, state} = pop_in(state.tasks[ref]) - IO.puts "Got #{inspect(result)} for URL #{inspect url}" + IO.puts("Got #{inspect(result)} for URL #{inspect url}") {:noreply, state} end # If the task fails... def handle_info({:DOWN, ref, _, _, reason}, state) do {url, state} = pop_in(state.tasks[ref]) - IO.puts "URL #{inspect url} failed with reason #{inspect(reason)}" + IO.puts("URL #{inspect url} failed with reason #{inspect(reason)}") {:noreply, state} end end diff --git a/lib/elixir/lib/task/supervisor.ex b/lib/elixir/lib/task/supervisor.ex index 6086b2a18fe..8561629d355 100644 --- a/lib/elixir/lib/task/supervisor.ex +++ b/lib/elixir/lib/task/supervisor.ex @@ -498,7 +498,7 @@ defmodule Task.Supervisor do Starts a task as a child of the given `supervisor`. Task.Supervisor.start_child(MyTaskSupervisor, fn -> - IO.puts "I am running in a task" + IO.puts("I am running in a task") end) Note that the spawned process is not linked to the caller, but diff --git a/lib/elixir/pages/getting-started/basic-types.md b/lib/elixir/pages/getting-started/basic-types.md index 43ebb304eac..0abe68b910e 100644 --- a/lib/elixir/pages/getting-started/basic-types.md +++ b/lib/elixir/pages/getting-started/basic-types.md @@ -322,7 +322,7 @@ iex> 1 == 2.0 false ``` -However, you can use the strict comparison operator [`===`](`===/2`) and [`!==`](`!==/2`) if you want to distinguish between integers and floats (that's the only difference between these operators): +However, you can use the strict comparison operator [`===`](`===/2`) and [`!==`](`!==/2`) if you want to distinguish between integers and floats: ```elixir iex> 1 === 1.0 diff --git a/lib/elixir/pages/getting-started/binaries-strings-and-charlists.md b/lib/elixir/pages/getting-started/binaries-strings-and-charlists.md index 3e0a22a4f5f..e19fe5fab59 100644 --- a/lib/elixir/pages/getting-started/binaries-strings-and-charlists.md +++ b/lib/elixir/pages/getting-started/binaries-strings-and-charlists.md @@ -184,7 +184,7 @@ iex> String.valid?(<<239, 191, 19>>) false ``` -The string concatenation operator `<>` is actually a binary concatenation operator: +The string concatenation operator [`<>`](`<>/2`) is actually a binary concatenation operator: ```elixir iex> "a" <> "ha" @@ -243,7 +243,7 @@ iex> [?h, ?e, ?l, ?l, ?o] ~c"hello" ``` -The `~c` sigil (we'll cover sigils later in the ["Sigils"](sigils.md) chapter) indicates the fact that we are dealing with a charlist and not a regular string. +The [`~c`](`Kernel.sigil_c/2`) sigil (we'll cover sigils later in the ["Sigils"](sigils.md) chapter) indicates the fact that we are dealing with a charlist and not a regular string. Instead of containing bytes, a charlist contains integer code points. However, the list is only printed as a sigil if all code points are within the ASCII range: @@ -283,7 +283,7 @@ iex> to_string(1) The functions above are polymorphic, in other words, they accept many shapes: not only do they convert charlists to strings (and vice-versa), they can also convert integers, atoms, and so on. -String (binary) concatenation uses the `<>` operator but charlists, being lists, use the list concatenation operator `++`: +String (binary) concatenation uses the [`<>`](`<>/2`) operator but charlists, being lists, use the list concatenation operator [`++`](`++/2`): ```elixir iex> ~c"this " <> ~c"fails" diff --git a/lib/elixir/pages/getting-started/debugging.md b/lib/elixir/pages/getting-started/debugging.md index 0be3fb8b4e7..8b503106381 100644 --- a/lib/elixir/pages/getting-started/debugging.md +++ b/lib/elixir/pages/getting-started/debugging.md @@ -46,7 +46,7 @@ It is also very common to use `IO.inspect/2` with `binding/0`, which returns all ```elixir def some_fun(a, b, c) do - IO.inspect binding() + IO.inspect(binding()) ... end ``` diff --git a/lib/elixir/pages/getting-started/module-attributes.md b/lib/elixir/pages/getting-started/module-attributes.md index 4ebfee34283..c1eba8ee8b9 100644 --- a/lib/elixir/pages/getting-started/module-attributes.md +++ b/lib/elixir/pages/getting-started/module-attributes.md @@ -73,7 +73,7 @@ So far, we have seen how to define attributes, but how can we read them? Let's s ```elixir defmodule MyServer do @service URI.parse("https://example.com") - IO.inspect @service + IO.inspect(@service) end ``` diff --git a/lib/elixir/pages/getting-started/modules-and-functions.md b/lib/elixir/pages/getting-started/modules-and-functions.md index a369a660827..3b08e43d6f4 100644 --- a/lib/elixir/pages/getting-started/modules-and-functions.md +++ b/lib/elixir/pages/getting-started/modules-and-functions.md @@ -143,8 +143,8 @@ defmodule Concat do end end -IO.puts Concat.join("Hello", "world") #=> Hello world -IO.puts Concat.join("Hello", "world", "_") #=> Hello_world +IO.puts(Concat.join("Hello", "world")) #=> Hello world +IO.puts(Concat.join("Hello", "world", "_")) #=> Hello_world ``` Any expression is allowed to serve as a default value, but it won't be evaluated during the function definition. Every time the function is invoked and any of its default values have to be used, the expression for that default value will be evaluated: @@ -182,9 +182,9 @@ defmodule Concat do end end -IO.puts Concat.join("Hello", "world") #=> Hello world -IO.puts Concat.join("Hello", "world", "_") #=> Hello_world -IO.puts Concat.join("Hello") #=> Hello +IO.puts(Concat.join("Hello", "world")) #=> Hello world +IO.puts(Concat.join("Hello", "world", "_")) #=> Hello_world +IO.puts(Concat.join("Hello")) #=> Hello ``` When a variable is not used by a function or a clause, we add a leading underscore (`_`) to its name to signal this intent. This rule is also covered in our [Naming Conventions](../references/naming-conventions.md#underscore-_foo) document. @@ -194,12 +194,12 @@ When using default values, one must be careful to avoid overlapping function def ```elixir defmodule Concat do def join(a, b) do - IO.puts "***First join" + IO.puts("***First join") a <> b end def join(a, b, sep \\ " ") do - IO.puts "***Second join" + IO.puts("***Second join") a <> sep <> b end end @@ -219,13 +219,13 @@ $ iex concat.ex ``` ```elixir -iex> Concat.join "Hello", "world" +iex> Concat.join("Hello", "world") ***First join "Helloworld" ``` ```elixir -iex> Concat.join "Hello", "world", "_" +iex> Concat.join("Hello", "world", "_") ***Second join "Hello_world" ``` diff --git a/lib/elixir/pages/getting-started/try-catch-and-rescue.md b/lib/elixir/pages/getting-started/try-catch-and-rescue.md index 5c1dd23fcac..a2e0c2c5c32 100644 --- a/lib/elixir/pages/getting-started/try-catch-and-rescue.md +++ b/lib/elixir/pages/getting-started/try-catch-and-rescue.md @@ -224,7 +224,7 @@ iex> defmodule RunAfter do ...> def without_even_trying do ...> raise "oops" ...> after -...> IO.puts "cleaning up!" +...> IO.puts("cleaning up!") ...> end ...> end iex> RunAfter.without_even_trying diff --git a/lib/elixir/pages/meta-programming/macros.md b/lib/elixir/pages/meta-programming/macros.md index a3261ddcbab..58e7eb0e7bd 100644 --- a/lib/elixir/pages/meta-programming/macros.md +++ b/lib/elixir/pages/meta-programming/macros.md @@ -38,9 +38,9 @@ and play with those definitions: ```elixir iex> require Unless -iex> Unless.macro_unless(true, do: IO.puts "this should never be printed") +iex> Unless.macro_unless(true, do: IO.puts("this should never be printed")) nil -iex> Unless.fun_unless(true, do: IO.puts "this should never be printed") +iex> Unless.fun_unless(true, do: IO.puts("this should never be printed")) "this should never be printed" nil ``` @@ -50,7 +50,7 @@ In our *macro* implementation, the sentence was not printed, although it was pri In other words, when invoked as: ```elixir -Unless.macro_unless(true, do: IO.puts "this should never be printed") +Unless.macro_unless(true, do: IO.puts("this should never be printed")) ``` Our `macro_unless` macro received the following: diff --git a/lib/elixir/pages/mix-and-otp/distributed-tasks.md b/lib/elixir/pages/mix-and-otp/distributed-tasks.md index 608fd3c2dd3..88ea24f83c8 100644 --- a/lib/elixir/pages/mix-and-otp/distributed-tasks.md +++ b/lib/elixir/pages/mix-and-otp/distributed-tasks.md @@ -38,7 +38,7 @@ Let's define a module named `Hello` in this shell: ```elixir iex> defmodule Hello do -...> def world, do: IO.puts "hello world" +...> def world, do: IO.puts("hello world") ...> end ``` @@ -102,7 +102,7 @@ So far we have explored tasks that are started and run in isolation, without reg ```elixir task = Task.async(fn -> compute_something_expensive() end) -res = compute_something_else() +res = compute_something_else() res + Task.await(task) ```