Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions getting-started/basic-types.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:

Expand Down
4 changes: 2 additions & 2 deletions getting-started/binaries-strings-and-char-lists.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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 `?`:

Expand Down Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion getting-started/case-cond-and-if.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion getting-started/introduction.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion getting-started/meta/macros.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions getting-started/mix-otp/genevent.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 ->
Expand Down
8 changes: 4 additions & 4 deletions getting-started/mix-otp/introduction-to-mix.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions getting-started/mix-otp/supervisor-and-application.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions getting-started/mix-otp/task-and-gen-tcp.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```

Expand Down
2 changes: 1 addition & 1 deletion getting-started/sigils.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down