Skip to content

Commit 9de7205

Browse files
committed
backticks and cases corrected
1 parent 43d3405 commit 9de7205

11 files changed

+26
-26
lines changed

_posts/2013-12-11-elixir-s-new-continuable-enumerators.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ the basis of a zip function. Without interleaving you cannot implement
8989

9090
The underlying problem, in both cases, is that the producer is fully in control.
9191
The producer simply pushes out as many elements to the consumer as it wants and
92-
then says "I'm done". There's no way aside from `throw`/`raise` for a consumer
92+
then says "I'm done". There's no way aside from `throw/raise` for a consumer
9393
to tell a producer "stop producing". There is definitely no way to tell a
9494
producer "stop for now but be prepared to continue where you left off later".
9595

getting-started/alias-require-and-import.markdown

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ redirect_from: /getting_started/13.html
1010

1111
In order to facilitate software reuse, Elixir provides three directives. As we are going to see below, they are called directives because they have **lexical scope**.
1212

13-
## alias
13+
## `alias`
1414

1515
`alias` allows you to set up aliases for any given module name. Imagine our `Math` module uses a special list implementation for doing math specific operations:
1616

@@ -59,7 +59,7 @@ end
5959

6060
In the example above, since we are invoking `alias` inside the function `plus/2`, the alias will just be valid inside the function `plus/2`. `minus/2` won't be affected at all.
6161

62-
## require
62+
## `require`
6363

6464
Elixir provides macros as a mechanism for meta-programming (writing code that generates code).
6565

@@ -78,7 +78,7 @@ In Elixir, `Integer.is_odd/1` is defined as a macro so that it can be used as a
7878

7979
In general a module does not need to be required before usage, except if we want to use the macros available in that module. An attempt to call a macro that was not loaded will raise an error. Note that like the `alias` directive, `require` is also lexically scoped. We will talk more about macros in a later chapter.
8080

81-
## import
81+
## `import`
8282

8383
We use `import` whenever we want to easily access functions or macros from other modules without using the fully-qualified name. For instance, if we want to use the `duplicate/2` function from the `List` module several times, we can simply import it:
8484

getting-started/case-cond-and-if.markdown

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ redirect_from: /getting_started/5.html
1010

1111
In this chapter, we will learn about the `case`, `cond` and `if` control-flow structures.
1212

13-
## case
13+
## `case`
1414

1515
`case` allows us to compare a value against many patterns until we find a matching one:
1616

@@ -133,7 +133,7 @@ iex> f.(-1, 3)
133133

134134
The number of arguments in each anonymous function clause needs to be the same, otherwise an error is raised.
135135

136-
## cond
136+
## `cond`
137137

138138
`case` is useful when you need to match against different values. However, in many circumstances, we want to check different conditions and find the first one that evaluates to true. In such cases, one may use `cond`:
139139

@@ -174,7 +174,7 @@ iex> cond do
174174
"1 is considered as true"
175175
```
176176

177-
## if and unless
177+
## `if` and `unless`
178178

179179
Besides `case` and `cond`, Elixir also provides the macros `if/2` and `unless/2` which are useful when you need to check for just one condition:
180180

@@ -204,16 +204,16 @@ iex> if nil do
204204

205205
> Note: An interesting note regarding `if/2` and `unless/2` is that they are implemented as macros in the language; they aren't special language constructs as they would be in many languages. You can check the documentation and the source of `if/2` in [the `Kernel` module docs](/docs/stable/elixir/Kernel.html). The `Kernel` module is also where operators like `+/2` and functions like `is_function/2` are defined, all automatically imported and available in your code by default.
206206
207-
## `do`/`end` blocks
207+
## `do/end` blocks
208208

209-
At this point, we have learned four control structures: `case`, `cond`, `if` and `unless`, and they were all wrapped in `do`/`end` blocks. It happens we could also write `if` as follows:
209+
At this point, we have learned four control structures: `case`, `cond`, `if` and `unless`, and they were all wrapped in `do/end` blocks. It happens we could also write `if` as follows:
210210

211211
```iex
212212
iex> if true, do: 1 + 2
213213
3
214214
```
215215

216-
In Elixir, `do`/`end` blocks are a convenience for passing a group of expressions to `do:`. These are equivalent:
216+
In Elixir, `do/end` blocks are a convenience for passing a group of expressions to `do:`. These are equivalent:
217217

218218
```iex
219219
iex> if true do
@@ -235,7 +235,7 @@ iex> if false, do: :this, else: :that
235235
:that
236236
```
237237

238-
One thing to keep in mind when using `do`/`end` blocks is they are always bound to the outermost function call. For example, the following expression:
238+
One thing to keep in mind when using `do/end` blocks is they are always bound to the outermost function call. For example, the following expression:
239239

240240
```iex
241241
iex> is_number if true do

getting-started/io-and-the-file-system.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ as, in case of an error, `File.read/1` will return `{:error, reason}` and the pa
8484

8585
If you don't want to handle a possible error (i.e., you want it to bubble up), prefer using `File.read!/1`.
8686

87-
## The Path module
87+
## The `Path` module
8888

8989
The majority of the functions in the `File` module expect paths as arguments. Most commonly, those paths will be regular binaries. The [`Path`](/docs/stable/elixir/Path.html) module provides facilities for working with such paths:
9090

getting-started/mix-otp/agent.markdown

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ end
139139

140140
You can read more about ExUnit cases in the [`ExUnit.Case` module documentation](/docs/stable/ex_unit/ExUnit.Case.html) and more about callbacks in [`ExUnit.Callbacks` docs](/docs/stable/ex_unit/ExUnit.Callbacks.html).
141141

142-
## Other Agent actions
142+
## Other agent actions
143143

144144
Besides getting a value and updating the agent state, agents allow us to get a value and update the agent state in one function call via `Agent.get_and_update/2`. Let's implement a `KV.Bucket.delete/2` function that deletes a key from the bucket, returning its current value:
145145

@@ -154,9 +154,9 @@ def delete(bucket, key) do
154154
end
155155
```
156156

157-
Now it is your turn to write a test for the functionality above! Also, be sure to explore the documentation for Agents to learn more about them.
157+
Now it is your turn to write a test for the functionality above! Also, be sure to explore the documentation for agents to learn more about them.
158158

159-
## Client/Server in Agents
159+
## Client/Server in agents
160160

161161
Before we move on to the next chapter, let's discuss the client/server dichotomy in agents. Let's expand the `delete/2` function we have just implemented:
162162

getting-started/mix-otp/genserver.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ Observe that we were able to considerably change the server implementation witho
245245

246246
Finally, different from the other callbacks, we have defined a "catch-all" clause for `handle_info/2` that discards any unknown message. To understand why, let's move on to the next section.
247247

248-
## call, cast or info?
248+
## `call`, `cast` or `info`?
249249

250250
So far we have used three callbacks: `handle_call/3`, `handle_cast/2` and `handle_info/2`. Deciding when to use each is straightforward:
251251

getting-started/mix-otp/supervisor-and-application.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ When things fail, your first reaction may be: "let's rescue those errors". But,
1414

1515
In this chapter, we are going to learn about supervisors and also about applications. We are going to create not one, but two supervisors, and use them to supervise our processes.
1616

17-
## Our first Supervisor
17+
## Our first supervisor
1818

1919
Creating a supervisor is not much different from creating a GenServer. We are going to define a module named `KV.Supervisor`, which will use the [Supervisor](/docs/stable/elixir/Supervisor.html) behaviour, inside the `lib/kv/supervisor.ex` file:
2020

getting-started/processes.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Elixir's processes should not be confused with operating system processes. Proce
1414

1515
In this chapter, we will learn about the basic constructs for spawning new processes, as well as sending and receiving messages between different processes.
1616

17-
## spawn
17+
## `spawn`
1818

1919
The basic mechanism for spawning new processes is with the auto-imported `spawn/1` function:
2020

@@ -47,7 +47,7 @@ true
4747

4848
Processes get much more interesting when we are able to send and receive messages.
4949

50-
## send and receive
50+
## `send` and `receive`
5151

5252
We can send messages to a process with `send/2` and receive them with `receive/1`:
5353

getting-started/protocols.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ end
116116

117117
If desired, you could come up with your own semantics for a user being blank. Not only that, you could use structs to build more robust data types, like queues, and implement all relevant protocols, such as `Enumerable` and possibly `Blank`, for this data type.
118118

119-
In many cases though, developers may want to provide a default implementation for structs, as explicitly implementing the protocol for all structs can be tedious. That's when falling back to Any comes in handy.
119+
In many cases though, developers may want to provide a default implementation for structs, as explicitly implementing the protocol for all structs can be tedious. That's when falling back to `Any` comes in handy.
120120

121-
## Falling back to Any
121+
## Falling back to `Any`
122122

123123
It may be convenient to provide a default implementation for all types. This can be achieved by setting `@fallback_to_any` to `true` in the protocol definition:
124124

getting-started/recursion.markdown

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ The second definition matches the pattern and has no guard so it will be execute
4949
Our `msg` is printed and `print_multiple_times/2` is called again this time with the second argument set to `1`.
5050
Because `n` is now set to `1`, the guard in our first definition of `print_multiple_times/2` evaluates to true, and we execute this particular definition. The `msg` is printed, and there is nothing left to execute.
5151

52-
We defined `print_multiple_times/2` so that no matter what number is passed as the second argument it either triggers our first definition (known as a "base case") or it triggers our second definition which will ensure that we get exactly one step closer to our base case.
52+
We defined `print_multiple_times/2` so that no matter what number is passed as the second argument it either triggers our first definition (known as a _base case_) or it triggers our second definition which will ensure that we get exactly one step closer to our base case.
5353

54-
## "Reduce" and "map" algorithms
54+
## Reduce and map algorithms
5555

5656
Let's now see how we can use the power of recursion to sum a list of numbers:
5757

@@ -82,7 +82,7 @@ sum_list [], 6
8282

8383
When the list is empty, it will match the final clause which returns the final result of `6`.
8484

85-
The process of taking a list and "reducing" it down to one value is known as a "reduce" algorithm and is central to functional programming.
85+
The process of taking a list and _reducing_ it down to one value is known as a _reduce algorithm_ and is central to functional programming.
8686

8787
What if we instead want to double all of the values in our list?
8888

@@ -100,7 +100,7 @@ end
100100
Math.double_each([1, 2, 3]) #=> [2, 4, 6]
101101
```
102102

103-
Here we have used recursion to traverse a list doubling each element and returning a new list. The process of taking a list and "mapping" over it is known as a "map" algorithm.
103+
Here we have used recursion to traverse a list doubling each element and returning a new list. The process of taking a list and _mapping_ over it is known as a _map algorithm_.
104104

105105
Recursion and [tail call](http://en.wikipedia.org/wiki/Tail_call) optimization are an important part of Elixir and are commonly used to create loops. However, when programming in Elixir you will rarely use recursion as above to manipulate lists.
106106

getting-started/where-to-go-next.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Remember that in case of any difficulties, you can always visit the **#elixir-la
2828

2929
Don't forget that you can also check the [source code of Elixir itself](https://github.com/elixir-lang/elixir), which is mostly written in Elixir (mainly the `lib` directory), or [explore Elixir's documentation](/docs.html).
3030

31-
## A Byte of Erlang
31+
## A byte of Erlang
3232

3333
As the main page of this site puts it:
3434

0 commit comments

Comments
 (0)