Skip to content

Commit

Permalink
Merge pull request #1022 from devloglogan/file_reading_typos
Browse files Browse the repository at this point in the history
corrected mixed up binary/term functions in file reading
  • Loading branch information
BrooklinJazz authored Aug 1, 2023
2 parents 1bd8382 + cbc235a commit 237f6a0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion exercises/score_tracker.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ defmodule ScoreTracker do
def start_link(_opts) do
end

def score(score_tracker_pid, amount) do
def add_points(score_tracker_pid, amount) do
end

def current_score(score_tracker_pid) do
Expand Down
4 changes: 2 additions & 2 deletions reading/file.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ File.write("data/erlang_term", %{1 => 2})

To get around these issues we can use `:erlang.binary_to_term/1` and `:erlang.term_to_binary/1` which convert an elixir term to and from binary.

When creating the file, we need to convert the Elixir term into binary using `:erlang.binary_to_term`
When creating the file, we need to convert the Elixir term into binary using `:erlang.term_to_binary/1`

<!-- livebook:{"break_markdown":true} -->

Expand All @@ -246,7 +246,7 @@ end
:erlang.term_to_binary(%{key: "value"})
```

When reading the saved binary, we need to convert it back into an elixir term using `:erlang.term_to_binary/1`.
When reading the saved binary, we need to convert it back into an elixir term using `:erlang.binary_to_term/1`.

<!-- livebook:{"break_markdown":true} -->

Expand Down
4 changes: 2 additions & 2 deletions reading/genservers.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ defmodule CounterServer do
end
```

Using the GenServer above, here's an example of sending an asynchronous message with `GenServer.cast/2` and an asynchronous message with `GenServer.call/3`.
Using the GenServer above, here's an example of sending an asynchronous message with `GenServer.cast/2` and a synchronous message with `GenServer.call/3`.

```elixir
{:ok, pid} = GenServer.start_link(CounterServer, [])
Expand Down Expand Up @@ -450,7 +450,7 @@ GenServer.cast(NamedCounter, :increment)
:sys.get_state(NamedCounter)
```

However some do not. of needed we can use `Process.whereis/1` to find the pid of a named process.
However, some do not. If needed, we can use `Process.whereis/1` to find the pid of a named process.

```elixir
Process.whereis(NamedCounter)
Expand Down
2 changes: 1 addition & 1 deletion reading/phoenix_authentication.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ The client sends the token whenever it makes a request, and the server can use t

## Generators

Phoenix provides the following [mix phx.gen.auth](https://hexdocs.pm/phoenix/mix_phx_gen_auth.html) command to generate all of the scaffolding we need to auth authentication in our system.
Phoenix provides the following [mix phx.gen.auth](https://hexdocs.pm/phoenix/mix_phx_gen_auth.html) command to generate all of the scaffolding we need for authentication in our system.

```
mix phx.gen.auth Accounts User users
Expand Down
2 changes: 1 addition & 1 deletion reading/task.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ spawn_pid =

When we want to execute some code in a process, we shouldn't use [Kernel.spawn/1](https://hexdocs.pm/elixir/Kernel.html#spawn/1) or [Kernel.spawn_link/1](https://hexdocs.pm/elixir/Kernel.html#spawn_link/1) directly. Instead, we should rely on the [Task](https://hexdocs.pm/elixir/Task.html) module. The [Task](https://hexdocs.pm/elixir/Task.html) module allows us to spawn a process, perform some work in that process, then end the process when our work is finished.

[Task](https://hexdocs.pm/elixir/Task.html) is also OTP-compliant, meaning it conform to certain OTP conventions that improve error handling, and allow them to start under a supervisor.
[Task](https://hexdocs.pm/elixir/Task.html) is also OTP-compliant, meaning it conforms to certain OTP conventions that improve error handling, and allow them to start under a supervisor.

## Fire-and-Forget

Expand Down

0 comments on commit 237f6a0

Please sign in to comment.