Skip to content

Commit 28d7fc3

Browse files
author
José Valim
committed
Merge pull request #2559 from jwarwick/keyword_docs
Fixing doc typos in Keyword
2 parents 7f4df95 + 9fa2798 commit 28d7fc3

File tree

1 file changed

+45
-32
lines changed

1 file changed

+45
-32
lines changed

lib/elixir/lib/keyword.ex

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ defmodule Keyword do
99
behave exactly as a dictionary and mimic the API defined
1010
by the `Dict` behaviour.
1111
12-
For example, `Keyword.get` will get the first entry matching
12+
For example, `Keyword.get/3` will get the first entry matching
1313
the given key, regardless if duplicated entries exist.
14-
Similarly, `Keyword.put` and `Keyword.delete` ensure all
14+
Similarly, `Keyword.put/3` and `Keyword.delete/3` ensure all
1515
duplicated entries for a given key are removed when invoked.
1616
1717
A handful of functions exist to handle duplicated keys, in
18-
particular, `from_enum` allows creating a new keywords without
19-
removing duplicated keys, `get_values` returns all values for
20-
a given key and `delete_first` deletes just one of the existing
18+
particular, `Enum.into/2` allows creating new keywords without
19+
removing duplicated keys, `get_values/2` returns all values for
20+
a given key and `delete_first/2` deletes just one of the existing
2121
entries.
2222
2323
Since a keyword list is simply a list, all the operations defined
24-
in `Enum` and `List` can also be applied.
24+
in `Enum` and `List` can be applied.
2525
"""
2626

2727
@compile :inline_list_funcs
@@ -34,7 +34,7 @@ defmodule Keyword do
3434
@type t(value) :: [{key, value}]
3535

3636
@doc """
37-
Checks if the given argument is a keywords list or not.
37+
Checks if the given argument is a keyword list or not.
3838
"""
3939
@spec keyword?(term) :: boolean
4040
def keyword?([{key, _value} | rest]) when is_atom(key) do
@@ -56,7 +56,7 @@ defmodule Keyword do
5656
Creates a keyword from an enumerable.
5757
5858
Duplicated entries are removed, the latest one prevails.
59-
I.e. differently from `Enum.into(enumerable, [])`,
59+
Unlike `Enum.into(enumerable, [])`,
6060
`Keyword.new(enumerable)` guarantees the keys are unique.
6161
6262
## Examples
@@ -76,7 +76,7 @@ defmodule Keyword do
7676
Creates a keyword from an enumerable via the transformation function.
7777
7878
Duplicated entries are removed, the latest one prevails.
79-
I.e. differently from `Enum.into(enumerable, [], fun)`,
79+
Unlike `Enum.into(enumerable, [], fun)`,
8080
`Keyword.new(enumerable, fun)` guarantees the keys are unique.
8181
8282
## Examples
@@ -96,7 +96,7 @@ defmodule Keyword do
9696
@doc """
9797
Gets the value for a specific `key`.
9898
99-
If `key` does not exist, return default value (`nil` if no default value).
99+
If `key` does not exist, return the default value (`nil` if no default value).
100100
101101
If duplicated entries exist, the first one is returned.
102102
Use `get_values/2` to retrieve all entries.
@@ -124,6 +124,7 @@ defmodule Keyword do
124124

125125
@doc """
126126
Fetches the value for a specific `key` and returns it in a tuple.
127+
127128
If the `key` does not exist, returns `:error`.
128129
129130
## Examples
@@ -144,8 +145,9 @@ defmodule Keyword do
144145
end
145146

146147
@doc """
147-
Fetches the value for specific `key`. If `key` does not exist,
148-
a `KeyError` is raised.
148+
Fetches the value for specific `key`.
149+
150+
If `key` does not exist, a `KeyError` is raised.
149151
150152
## Examples
151153
@@ -184,8 +186,9 @@ defmodule Keyword do
184186
end
185187

186188
@doc """
187-
Returns all keys from the keyword list. Duplicated
188-
keys appear duplicated in the final list of keys.
189+
Returns all keys from the keyword list.
190+
191+
Duplicated keys appear duplicated in the final list of keys.
189192
190193
## Examples
191194
@@ -217,6 +220,7 @@ defmodule Keyword do
217220

218221
@doc """
219222
Deletes the entries in the keyword list for a `key` with `value`.
223+
220224
If no `key` with `value` exists, returns the keyword list unchanged.
221225
222226
## Examples
@@ -238,8 +242,9 @@ defmodule Keyword do
238242

239243
@doc """
240244
Deletes the entries in the keyword list for a specific `key`.
245+
241246
If the `key` does not exist, returns the keyword list unchanged.
242-
Use `delete_first` to delete just the first entry in case of
247+
Use `delete_first/2` to delete just the first entry in case of
243248
duplicated keys.
244249
245250
## Examples
@@ -261,6 +266,7 @@ defmodule Keyword do
261266

262267
@doc """
263268
Deletes the first entry in the keyword list for a specific `key`.
269+
264270
If the `key` does not exist, returns the keyword list unchanged.
265271
266272
## Examples
@@ -319,7 +325,9 @@ defmodule Keyword do
319325
end
320326

321327
@doc """
322-
Checks if two keywords are equal. I.e. they contain
328+
Checks if two keywords are equal.
329+
330+
Two keywords are considered to be equal if they contain
323331
the same keys and those keys contain the same values.
324332
325333
## Examples
@@ -334,8 +342,9 @@ defmodule Keyword do
334342
end
335343

336344
@doc """
337-
Merges two keyword lists into one. If they have duplicated
338-
entries, the one given as second argument wins.
345+
Merges two keyword lists into one.
346+
347+
If they have duplicated keys, the one given in the second argument wins.
339348
340349
## Examples
341350
@@ -350,8 +359,9 @@ defmodule Keyword do
350359
end
351360

352361
@doc """
353-
Merges two keyword lists into one. If they have duplicated
354-
entries, the given function is invoked to solve conflicts.
362+
Merges two keyword lists into one.
363+
364+
If they have duplicated keys, the given function is invoked to solve conflicts.
355365
356366
## Examples
357367
@@ -392,10 +402,11 @@ defmodule Keyword do
392402
end
393403

394404
@doc """
395-
Updates the `key` with the given function. If the `key` does
396-
not exist, raises `KeyError`.
405+
Updates the `key` with the given function.
406+
407+
If the `key` does not exist, raises `KeyError`.
397408
398-
If there are duplicated entries, they are all removed and only the first one
409+
If there are duplicated keys, they are all removed and only the first one
399410
is updated.
400411
401412
## Examples
@@ -425,10 +436,11 @@ defmodule Keyword do
425436
end
426437

427438
@doc """
428-
Updates the `key` with the given function. If the `key` does
429-
not exist, inserts the given `initial` value.
439+
Updates the `key` with the given function.
440+
441+
If the `key` does not exist, inserts the given `initial` value.
430442
431-
If there are duplicated entries, they are all removed and only the first one
443+
If there are duplicated keys, they are all removed and only the first one
432444
is updated.
433445
434446
## Examples
@@ -455,8 +467,9 @@ defmodule Keyword do
455467

456468
@doc """
457469
Takes all entries corresponding to the given keys and extracts them into a
458-
separate keyword list. Returns a tuple with the new list and the old list
459-
with removed keys.
470+
separate keyword list.
471+
472+
Returns a tuple with the new list and the old list with removed keys.
460473
461474
Keys for which there are no entires in the keyword list are ignored.
462475
@@ -508,7 +521,7 @@ defmodule Keyword do
508521
end
509522

510523
@doc """
511-
Drops the given keys from the dict.
524+
Drops the given keys from the keyword list.
512525
513526
Duplicated keys are preserved in the new keyword list.
514527
@@ -531,7 +544,7 @@ defmodule Keyword do
531544
Returns the first value associated with `key` in the keyword
532545
list as well as the keyword list without `key`.
533546
534-
All duplicated entries are removed. See `pop_first/3` for
547+
All duplicated keys are removed. See `pop_first/3` for
535548
removing only the first entry.
536549
537550
## Examples
@@ -558,10 +571,10 @@ defmodule Keyword do
558571

559572
@doc """
560573
Returns the first value associated with `key` in the keyword
561-
list as well as the keyword list without that particular ocurrence
574+
list as well as the keyword list without that particular occurrence
562575
of `key`.
563576
564-
Duplicated entries are not removed.
577+
Duplicated keys are not removed.
565578
566579
## Examples
567580

0 commit comments

Comments
 (0)