From 00f26629daa66a51efa050c51e8c5ca1ab62eeca Mon Sep 17 00:00:00 2001 From: sarayourfriend Date: Sun, 1 Sep 2024 04:18:46 +1000 Subject: [PATCH] Fix a few more minor typos (#13801) --- lib/elixir/pages/getting-started/comprehensions.md | 2 +- lib/elixir/pages/getting-started/module-attributes.md | 6 +++--- lib/elixir/pages/getting-started/protocols.md | 4 ++-- lib/elixir/pages/getting-started/try-catch-and-rescue.md | 2 +- lib/elixir/pages/getting-started/writing-documentation.md | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/elixir/pages/getting-started/comprehensions.md b/lib/elixir/pages/getting-started/comprehensions.md index e39d1c7bf95..f8e726a6379 100644 --- a/lib/elixir/pages/getting-started/comprehensions.md +++ b/lib/elixir/pages/getting-started/comprehensions.md @@ -1,6 +1,6 @@ # Comprehensions -In Elixir, it is common to loop over an Enumerable, often filtering out some results and mapping values into another list. Comprehensions are syntactic sugar for such constructs: they group those common tasks into the `for` special form. +In Elixir, it is common to loop over an `Enumerable`, often filtering out some results and mapping values into another list. Comprehensions are syntactic sugar for such constructs: they group those common tasks into the `for` special form. For example, we can map a list of integers into their squared values: diff --git a/lib/elixir/pages/getting-started/module-attributes.md b/lib/elixir/pages/getting-started/module-attributes.md index 3eaeec54c1c..4ebfee34283 100644 --- a/lib/elixir/pages/getting-started/module-attributes.md +++ b/lib/elixir/pages/getting-started/module-attributes.md @@ -173,7 +173,7 @@ Module attributes as constants and as temporary storage are most often used toge ## Going further -Libraries and frameworks can leverage module attributes to provide custom annotations. To see an example, look no further than Elixir's unit test framework called `ExUnit`. ExUnit uses module attributes for multiple different purposes: +Libraries and frameworks can leverage module attributes to provide custom annotations. To see an example, look no further than Elixir's unit test framework called `ExUnit`. `ExUnit` uses module attributes for multiple different purposes: ```elixir defmodule MyTest do @@ -187,8 +187,8 @@ defmodule MyTest do end ``` -In the example above, `ExUnit` stores the value of `async: true` in a module attribute to change how the module is compiled. Tags also work as annotations and they can be supplied multiple times, thanks to Elixir's ability to [accumulate attribute](`Module.register_attribute/3`). Then you can use tags to setup and filter tests, such as avoiding executing Unix specific tests while running your test suite on Windows. +In the example above, `ExUnit` stores the value of `async: true` in a module attribute to change how the module is compiled. Tags also work as annotations and they can be supplied multiple times, thanks to Elixir's ability to [accumulate attributes](`Module.register_attribute/3`). Then you can use tags to setup and filter tests, such as avoiding executing Unix specific tests while running your test suite on Windows. -To fully understand how ExUnit works, we'd need macros, so we will revisit this pattern in the Meta-programming guide and learn how to use module attributes as storage for custom annotations. +To fully understand how `ExUnit` works, we'd need macros, so we will revisit this pattern in the Meta-programming guide and learn how to use module attributes as storage for custom annotations. In the next chapters, we'll explore structs and protocols before moving to exception handling and other constructs like sigils and comprehensions. diff --git a/lib/elixir/pages/getting-started/protocols.md b/lib/elixir/pages/getting-started/protocols.md index 30993322419..3341114a5e8 100644 --- a/lib/elixir/pages/getting-started/protocols.md +++ b/lib/elixir/pages/getting-started/protocols.md @@ -42,7 +42,7 @@ iex> Utility.type(123) With protocols, however, we are no longer stuck having to continuously modify the same module to support more and more data types. For example, we could spread the `defimpl` calls above over multiple files and Elixir will dispatch the execution to the appropriate implementation based on the data type. Functions defined in a protocol may have more than one input, but the **dispatching will always be based on the data type of the first input**. -One of the most common protocols you may encounter is the `String.Chars` protocol: implementing its `to_string/1` function for your custom structs will tell the Elixir kernel how to represent them as strings. We will explore all built-in protocols later. For now, let's implement our own. +One of the most common protocols you may encounter is the `String.Chars` protocol: implementing its `to_string/1` function for your custom structs will tell the Elixir kernel how to represent them as strings. We will explore all the built-in protocols later. For now, let's implement our own. ## Example @@ -253,4 +253,4 @@ iex> inspect &(&1+2) "#Function<6.71889879/1 in :erl_eval.expr/5>" ``` -There are other protocols in Elixir but this covers the most common ones. You can learn more about protocols and implementations in the `Protocol` module. +There are other protocols in Elixir, but this covers the most common ones. You can learn more about protocols and implementations in the `Protocol` module. diff --git a/lib/elixir/pages/getting-started/try-catch-and-rescue.md b/lib/elixir/pages/getting-started/try-catch-and-rescue.md index 6590c397bb9..5c1dd23fcac 100644 --- a/lib/elixir/pages/getting-started/try-catch-and-rescue.md +++ b/lib/elixir/pages/getting-started/try-catch-and-rescue.md @@ -200,7 +200,7 @@ It is exactly this supervision system that makes constructs like `try/catch` and ## After -Sometimes it's necessary to ensure that a resource is cleaned up after some action that could potentially raise an error. The `try/after` construct allows you to do that. For example, we can open a file and use an `after` clause to close it -- even if something goes wrong: +Sometimes it's necessary to ensure that a resource is cleaned up after some action that could potentially raise an error. The `try/after` construct allows you to do that. For example, we can open a file and use an `after` clause to close it—even if something goes wrong: ```elixir iex> {:ok, file} = File.open("sample", [:utf8, :write]) diff --git a/lib/elixir/pages/getting-started/writing-documentation.md b/lib/elixir/pages/getting-started/writing-documentation.md index 8ed897bc36b..2e6dacdfc8a 100644 --- a/lib/elixir/pages/getting-started/writing-documentation.md +++ b/lib/elixir/pages/getting-started/writing-documentation.md @@ -104,7 +104,7 @@ We recommend that developers include examples in their documentation, often unde ## Documentation != Code comments -Elixir treats documentation and code comments as different concepts. Documentation is an explicit contract between you and users of your Application Programming Interface (API), be them third-party developers, co-workers, or your future self. Modules and functions must always be documented if they are part of your API. +Elixir treats documentation and code comments as different concepts. Documentation is an explicit contract between you and users of your Application Programming Interface (API), be they third-party developers, co-workers, or your future self. Modules and functions must always be documented if they are part of your API. Code comments are aimed at developers reading the code. They are useful for marking improvements, leaving notes (for example, why you had to resort to a workaround due to a bug in a library), and so forth. They are tied to the source code: you can completely rewrite a function and remove all existing code comments, and it will continue to behave the same, with no change to either its behavior or its documentation.