Skip to content

Commit cf13e04

Browse files
committed
Fix grammatical errors throughout getting-started
Fix conceptual, grammatical, and spelling errors in: - case-cond-and-if - enumerables-and-streams - keywords-and-maps - modules - processes
1 parent d2fba46 commit cf13e04

5 files changed

+10
-10
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ iex> if false, do: :this, else: :that
230230
:that
231231
```
232232

233-
`do/end` blocks are a syntatic convenience built on top of the keywords one. That's why `do/end` blocks do not require a comma between the previous argument the block. They are useful exactly because they remove the verbosity when writing blocks of code. These are equivalent:
233+
`do/end` blocks are a syntatic convenience built on top of the keywords one. That's why `do/end` blocks do not require a comma between the previous argument and the block. They are useful exactly because they remove the verbosity when writing blocks of code. These are equivalent:
234234

235235
```iex
236236
iex> if true do

getting-started/enumerables-and-streams.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ iex> Enum.reduce(1..3, 0, &+/2)
3131

3232
The functions in the Enum module are limited to, as the name says, enumerating values in data structures. For specific operations, like inserting and updating particular elements, you may need to reach for modules specific to the data type. For example, if you want to insert an element at a given position in a list, you should use the `List.insert_at/3` function from [the `List` module](/docs/stable/elixir/List.html), as it would make little sense to insert a value into, for example, a range.
3333

34-
We say the functions in the `Enum` module are polymorphic because they can work with diverse data types. In particular, the functions in the `Enum` module can work with any data type that implements [the `Enumerable` protocol](/docs/stable/elixir/Enumerable.html). We are going to discuss Protocols in a later chapter, for now we are going to move on to a specific kind of enumerable called streams.
34+
We say the functions in the `Enum` module are polymorphic because they can work with diverse data types. In particular, the functions in the `Enum` module can work with any data type that implements [the `Enumerable` protocol](/docs/stable/elixir/Enumerable.html). We are going to discuss Protocols in a later chapter, for now we are going to move on to a specific kind of enumerable called a stream.
3535

3636
## Eager vs Lazy
3737

getting-started/keywords-and-maps.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ iex> list[:a]
2525
1
2626
```
2727

28-
As you can see above, Elixir supports a special syntax for defining such lists, and underneath they just map to a list of tuples. Since they are simply lists, all operations available to lists. For example, we can use `++` to add new values to a keyword list:
28+
As you can see above, Elixir supports a special syntax for defining such lists, and underneath they just map to a list of tuples. Since they are simply lists, we can use all operations available to lists. For example, we can use `++` to add new values to a keyword list:
2929

3030
```iex
3131
iex> list ++ [c: 3]
@@ -152,7 +152,7 @@ iex> map = %{a: 1, b: 2}
152152
%{a: 1, b: 2}
153153
```
154154

155-
Another interesting property about maps is that they provide their own syntax for updating and accessing atom keys:
155+
Another interesting property of maps is that they provide their own syntax for updating and accessing atom keys:
156156

157157
```iex
158158
iex> map = %{:a => 1, 2 => :b}

getting-started/modules.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ defmodule Math do
132132
end
133133
```
134134

135-
And it will provide the same behaviour. You may use `do:` for one-liners but always `do`/`end` for functions spawning multiple lines.
135+
And it will provide the same behaviour. You may use `do:` for one-liners but always use `do`/`end` for functions spanning multiple lines.
136136

137137
## Function capturing
138138

@@ -173,7 +173,7 @@ iex> fun.(1)
173173

174174
The `&1` represents the first argument passed into the function. `&(&1+1)` above is exactly the same as `fn x -> x + 1 end`. The syntax above is useful for short function definitions.
175175

176-
If you want to call a function from a module, you can do `&Module.function()`:
176+
If you want to capture a function from a module, you can do `&Module.function()`:
177177

178178
```iex
179179
iex> fun = &List.flatten(&1, &2)

getting-started/processes.markdown

+4-4
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ $ elixir spawn.exs
141141

142142
This time the process failed and brought the parent process down as they are linked. Linking can also be done manually by calling `Process.link/1`. We recommend that you take a look at [the `Process` module](/docs/stable/elixir/Process.html) for other functionality provided by processes.
143143

144-
Process and links play an important role when building fault-tolerant systems. In Elixir applications, we often link our processes to supervisors which will detect when a process dies and start a new process in its place. This is only possible because processes are isolated and don't share anything by default. And if processes are isolated, there is no way a failure in a process will crash or corrupt the state of another.
144+
Processes and links play an important role when building fault-tolerant systems. In Elixir applications, we often link our processes to supervisors which will detect when a process dies and start a new process in its place. This is only possible because processes are isolated and don't share anything by default. And since processes are isolated, there is no way a failure in a process will crash or corrupt the state of another.
145145

146146
While other languages would require us to catch/handle exceptions, in Elixir we are actually fine with letting processes fail because we expect supervisors to properly restart our systems. "Failing fast" is a common philosophy when writing Elixir software!
147147

148-
`spawn/1` and `spawn_link/1` are the basic primitives for creating processes in Elixir. Although we have used them exclusively so far, most of the times we are going to use abstractions that build on top of them. Let's see the most common one, called tasks.
148+
`spawn/1` and `spawn_link/1` are the basic primitives for creating processes in Elixir. Although we have used them exclusively so far, most of the time we are going to use abstractions that build on top of them. Let's see the most common one, called tasks.
149149

150150
## Tasks
151151

@@ -164,7 +164,7 @@ Function: #Function<20.90072148/0 in :erl_eval.expr/5>
164164
(stdlib) proc_lib.erl:239: :proc_lib.init_p_do_apply/3
165165
```
166166

167-
Instead of `spawn/1` and `spawn_link/1`, we use `Task.start/1` and `Task.start_link/1` return `{:ok, pid}` rather than just the PID. This is what enables Tasks to be used in supervision trees. Furthermore, Tasks provides convenience functions, like `Task.async/1` and `Task.await/1`, and functionality to ease distribution.
167+
Instead of `spawn/1` and `spawn_link/1`, we use `Task.start/1` and `Task.start_link/1` to return `{:ok, pid}` rather than just the PID. This is what enables Tasks to be used in supervision trees. Furthermore, `Task` provides convenience functions, like `Task.async/1` and `Task.await/1`, and functionality to ease distribution.
168168

169169
We will explore those functionalities in the ***Mix and OTP guide***, for now it is enough to remember to use Tasks to get better error reports.
170170

@@ -240,6 +240,6 @@ iex> Agent.get(pid, fn map -> Map.get(map, :hello) end)
240240
:world
241241
```
242242

243-
A `:name` option could also be given to `Agent.start_link/2` and it would be automatically registered. Besides agents, Elixir provides an API for building generic servers (called GenServer), agents, tasks and more, all powered by processes underneath. Those, along with supervision trees, will be explored with more detail in the ***Mix and OTP guide*** which will build a complete Elixir application from start to finish.
243+
A `:name` option could also be given to `Agent.start_link/2` and it would be automatically registered. Besides agents, Elixir provides an API for building generic servers (called GenServer), tasks and more, all powered by processes underneath. Those, along with supervision trees, will be explored with more detail in the ***Mix and OTP guide*** which will build a complete Elixir application from start to finish.
244244

245245
For now, let's move on and explore the world of I/O in Elixir.

0 commit comments

Comments
 (0)