diff --git a/getting-started/basic-types.markdown b/getting-started/basic-types.markdown index c16859fd8..8a3fe7c8f 100644 --- a/getting-started/basic-types.markdown +++ b/getting-started/basic-types.markdown @@ -23,7 +23,7 @@ iex> {1, 2, 3} # tuple ## Basic arithmetic -Open up `iex` and type the following expressions: +Open up `iex` and type the following expressions: ```iex iex> 1 + 2 @@ -135,7 +135,7 @@ iex> "hellö" "hellö" ``` -> Note: if you are running on Windows, there is a chance your terminal does not use UTF-8 by default. You can change the encoding of your current session by running `chcp 65001` before entering iex. +> Note: if you are running on Windows, there is a chance your terminal does not use UTF-8 by default. You can change the encoding of your current session by running `chcp 65001` before entering IEx. Elixir also supports string interpolation: diff --git a/getting-started/binaries-strings-and-char-lists.markdown b/getting-started/binaries-strings-and-char-lists.markdown index e73c72456..b16b44b40 100644 --- a/getting-started/binaries-strings-and-char-lists.markdown +++ b/getting-started/binaries-strings-and-char-lists.markdown @@ -38,7 +38,7 @@ iex> String.length string 5 ``` -> Note: if you are running on Windows, there is a chance your terminal does not use UTF-8 by default. You can change the encoding of your current session by running `chcp 65001` before entering iex. +> Note: if you are running on Windows, there is a chance your terminal does not use UTF-8 by default. You can change the encoding of your current session by running `chcp 65001` before entering `iex`. UTF-8 requires one byte to represent the code points `h`, `e` and `o`, but two bytes to represent `ł`. In Elixir, you can get a code point's value by using `?`: @@ -168,7 +168,7 @@ iex> 'hello' 'hello' ``` -You can see that, instead of containing bytes, a char list contains the code points of the characters between single-quotes (note that iex will only output code points if any of the chars is outside the ASCII range). So while double-quotes represent a string (i.e. a binary), single-quotes represents a char list (i.e. a list). +You can see that, instead of containing bytes, a char list contains the code points of the characters between single-quotes (note that IEx will only output code points if any of the chars is outside the ASCII range). So while double-quotes represent a string (i.e. a binary), single-quotes represents a char list (i.e. a list). In practice, char lists are used mostly when interfacing with Erlang, in particular old libraries that do not accept binaries as arguments. You can convert a char list to a string and back by using the `to_string/1` and `to_char_list/1` functions: diff --git a/getting-started/case-cond-and-if.markdown b/getting-started/case-cond-and-if.markdown index 216de98bf..e44149692 100644 --- a/getting-started/case-cond-and-if.markdown +++ b/getting-started/case-cond-and-if.markdown @@ -122,7 +122,7 @@ iex> case :ok do Note anonymous functions can also have multiple clauses and guards: -```elixir +```iex iex> f = fn ...> x, y when x > 0 -> x + y ...> x, y -> x * y diff --git a/getting-started/introduction.markdown b/getting-started/introduction.markdown index 9b7b0526a..19a26c596 100644 --- a/getting-started/introduction.markdown +++ b/getting-started/introduction.markdown @@ -31,7 +31,7 @@ When you install Elixir, you will have three new executables: `iex`, `elixir` an For now, let's start by running `iex` (or `iex.bat` if you are on Windows) which stands for Interactive Elixir. In interactive mode, we can type any Elixir expression and get its result. Let's warm up with some basic expressions. -Open up `iex` and type the following expressions: +Open up `iex` and type the following expressions: ```iex Interactive Elixir - press Ctrl+C to exit (type h() ENTER for help) diff --git a/getting-started/meta/macros.markdown b/getting-started/meta/macros.markdown index ad2fcd825..9bced9458 100644 --- a/getting-started/meta/macros.markdown +++ b/getting-started/meta/macros.markdown @@ -227,7 +227,7 @@ Elixir also supports private macros via `defmacrop`. As private functions, these It is important that a macro is defined before its usage. Failing to define a macro before its invocation will raise an error at runtime, since the macro won't be expanded and will be translated to a function call: -```elixir +```iex iex> defmodule Sample do ...> def four, do: two + two ...> defmacrop two, do: 2 diff --git a/getting-started/mix-otp/dependencies-and-umbrella-apps.markdown b/getting-started/mix-otp/dependencies-and-umbrella-apps.markdown index 8a14688f7..440c74223 100644 --- a/getting-started/mix-otp/dependencies-and-umbrella-apps.markdown +++ b/getting-started/mix-otp/dependencies-and-umbrella-apps.markdown @@ -46,7 +46,7 @@ def deps do end ``` -This dependency refers to the latest version of plug in the 0.5.x version series that has been pushed to Hex. This is indicated by the `~>` preceding the version number. For more information on specifying version requirements, see the [documentation for the Version module](/docs/stable/elixir/#!Version.html). +This dependency refers to the latest version of Plug in the 0.5.x version series that has been pushed to Hex. This is indicated by the `~>` preceding the version number. For more information on specifying version requirements, see the [documentation for the Version module](/docs/stable/elixir/#!Version.html). Typically, stable releases are pushed to Hex. If you want to depend on an external dependency still in development, Mix is able to manage git dependencies, too: @@ -94,7 +94,7 @@ However, if you push every application as a separate project to a git repository For this reason, Mix supports "umbrella projects." Umbrella projects allow you to create one project that hosts many applications and push all of them to a single git repository. That is exactly the style we are going to explore in the next sections. -What we are going to do is create a new mix project. We are going to creatively name it `kv_umbrella`, and this new project will have both the existing `kv` application and the new `kv_server` application inside. The directory structure will look like this: +What we are going to do is create a new Mix project. We are going to creatively name it `kv_umbrella`, and this new project will have both the existing `kv` application and the new `kv_server` application inside. The directory structure will look like this: + kv_umbrella + apps diff --git a/getting-started/mix-otp/genevent.markdown b/getting-started/mix-otp/genevent.markdown index 20d6ec403..b26fe59dc 100644 --- a/getting-started/mix-otp/genevent.markdown +++ b/getting-started/mix-otp/genevent.markdown @@ -16,7 +16,7 @@ There are two events we are going to emit: one for every time a bucket is added Let's start a new `iex -S mix` session and explore the GenEvent API a bit: -```elixir +```iex iex> {:ok, manager} = GenEvent.start_link {:ok, #PID<0.83.0>} iex> GenEvent.sync_notify(manager, :hello) @@ -190,7 +190,7 @@ Run the test suite, and all tests should be green again. One last functionality worth exploring from `GenEvent` is the ability to consume its events as a stream: -```elixir +```iex iex> {:ok, manager} = GenEvent.start_link {:ok, #PID<0.83.0>} iex> spawn_link fn -> diff --git a/getting-started/mix-otp/introduction-to-mix.markdown b/getting-started/mix-otp/introduction-to-mix.markdown index 51afe65ad..9a36d8d9a 100644 --- a/getting-started/mix-otp/introduction-to-mix.markdown +++ b/getting-started/mix-otp/introduction-to-mix.markdown @@ -48,7 +48,7 @@ In this chapter, we will create our first project using Mix and explore differen When you install Elixir, besides getting the `elixir`, `elixirc` and `iex` executables, you also get an executable Elixir script named `mix`. -Let's create our first project by invoking `mix new` from the command line. We'll pass the project name as argument (`kv`, in this case), and tell mix that our main module should be the all-uppercase `KV`, instead of the default, which would have been `Kv`: +Let's create our first project by invoking `mix new` from the command line. We'll pass the project name as argument (`kv`, in this case), and tell Mix that our main module should be the all-uppercase `KV`, instead of the default, which would have been `Kv`: ```bash $ mix new kv --module KV @@ -69,7 +69,7 @@ Mix will create a directory named `kv` with a few files in it: Let's take a brief look at those generated files. -> Note: Mix is an Elixir executable. This means that in order to run `mix`, you need to have elixir's executable in your PATH. If not, you can run it by passing the script as argument to elixir: +> Note: Mix is an Elixir executable. This means that in order to run `mix`, you need to have Elixir's executable in your PATH. If not, you can run it by passing the script as argument to `elixir`: > > ```bash > $ bin/elixir bin/mix new kv --module KV @@ -81,7 +81,7 @@ Let's take a brief look at those generated files. > $ bin/elixir -S mix new kv --module KV > ``` > -> When using -S, elixir finds the script wherever it is in your PATH and executes it. +> When using -S, `elixir` finds the script wherever it is in your PATH and executes it. ## Project compilation @@ -215,7 +215,7 @@ Finally, the stacktrace relates to the failure itself, giving information about Mix supports the concept of "environments". They allow a developer to customize compilation and other options for specific scenarios. By default, Mix understands three environments: -* `:dev` - the one in which mix tasks (like `compile`) run by default +* `:dev` - the one in which Mix tasks (like `compile`) run by default * `:test` - used by `mix test` * `:prod` - the one you will use to put your project in production diff --git a/getting-started/mix-otp/supervisor-and-application.markdown b/getting-started/mix-otp/supervisor-and-application.markdown index e588f6a76..471e92c66 100644 --- a/getting-started/mix-otp/supervisor-and-application.markdown +++ b/getting-started/mix-otp/supervisor-and-application.markdown @@ -106,14 +106,14 @@ Oops, it's already started. Mix normally starts the whole hierarchy of applicati We can pass an option to Mix to ask it to not start our application. Let's give it a try by running `iex -S mix run --no-start`: -```elixir +```iex iex> Application.start(:kv) :ok ``` We can stop our `:kv` application as well as the `:logger` application, which is started by default with Elixir: -```elixir +```iex iex> Application.stop(:kv) :ok iex> Application.stop(:logger) @@ -122,21 +122,21 @@ iex> Application.stop(:logger) And let's try to start our application again: -```elixir +```iex iex> Application.start(:kv) {:error, {:not_started, :logger}} ``` Now we get an error because an application that `:kv` depends on (`:logger` in this case) isn't started. We need to either start each application manually in the correct order or call `Application.ensure_all_started` as follows: -```elixir +```iex iex> Application.ensure_all_started(:kv) {:ok, [:logger, :kv]} ``` Nothing really exciting happens but it shows how we can control our application. -> When you run `iex -S mix`, it is equivalent to running `iex -S mix run`. So whenever you need to pass more options to Mix when starting iex, it's just a matter of typing `iex -S mix run` and then passing any options the `run` command accepts. You can find more information about `run` by running `mix help run` in your shell. +> When you run `iex -S mix`, it is equivalent to running `iex -S mix run`. So whenever you need to pass more options to Mix when starting IEx, it's just a matter of typing `iex -S mix run` and then passing any options the `run` command accepts. You can find more information about `run` by running `mix help run` in your shell. ### The application callback diff --git a/getting-started/mix-otp/task-and-gen-tcp.markdown b/getting-started/mix-otp/task-and-gen-tcp.markdown index 0d9ff67c3..93ff49f9a 100644 --- a/getting-started/mix-otp/task-and-gen-tcp.markdown +++ b/getting-started/mix-otp/task-and-gen-tcp.markdown @@ -92,9 +92,9 @@ The `read_line/1` implementation receives data from the socket using `:gen_tcp.r This is pretty much all we need to implement our echo server. Let's give it a try! -Start an iex session inside the `kv_server` application with `iex -S mix`. Inside IEx, run: +Start an IEx session inside the `kv_server` application with `iex -S mix`. Inside IEx, run: -```elixir +```iex iex> KVServer.accept(4040) ``` diff --git a/getting-started/sigils.markdown b/getting-started/sigils.markdown index 21da80944..5e8300541 100644 --- a/getting-started/sigils.markdown +++ b/getting-started/sigils.markdown @@ -96,7 +96,7 @@ iex> ~w(foo bar bat)a Besides lowercase sigils, Elixir supports uppercase sigils to deal with escaping characters and interpolation. While both `~s` and `~S` will return strings, the former allows escape codes and interpolation while the latter does not: -```elixir +```iex iex> ~s(String with escape codes \x26 #{"inter" <> "polation"}) "String with escape codes & interpolation" iex> ~S(String without escape codes and without #{interpolation})