Skip to content

Commit

Permalink
Merge pull request #58 from pedropark99/revision-10
Browse files Browse the repository at this point in the history
Add a revision for Chapter 10
  • Loading branch information
pedropark99 authored Oct 5, 2024
2 parents 42ac728 + 49130fa commit 95e5786
Show file tree
Hide file tree
Showing 34 changed files with 150 additions and 143 deletions.
2 changes: 1 addition & 1 deletion Chapters/01-base64.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ at the sixth position in both binary sequences we had a 1 value. So any
position where we do not have both binary sequences setted to 1, we get
a 0 bit in the resulting binary sequence.

We loose information about the original bit values
We lose information about the original bit values
from both sequences in this case. Because we no longer know
if this 0 bit in the resulting binary sequence was produced by
combining 0 with 0, or 1 with 0, or 0 with 1.
Expand Down
4 changes: 2 additions & 2 deletions Chapters/01-memory.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ The example below demonstrates this idea.
#| auto_main: true
#| build_type: "run"
#| eval: false
// This does not compile succesfully!
// This does not compile successfully!
const a = [_]u8{0, 1, 2, 3, 4};
for (0..a.len) |i| {
const index = i;
Expand Down Expand Up @@ -297,7 +297,7 @@ bugs in your program [@zigdocs, see "Lifetime and Ownership"[^life] and "Undefin
```{zig}
#| auto_main: true
#| build_type: "run"
// This code compiles succesfully. But it has
// This code compiles successfully. But it has
// undefined behaviour. Never do this!!!
// ==== Variable
// The `r` object is undefined!
Expand Down
6 changes: 3 additions & 3 deletions Chapters/01-zig-weird.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ keyword `var` in Zig is similar to using the keywords `let mut` in Rust.

In the code example below, we are creating a new constant object called `age`.
This object stores a number representing the age of someone. However, this code example
does not compiles succesfully. Because on the next line of code, we are trying to change the value
does not compiles successfully. Because on the next line of code, we are trying to change the value
of the object `age` to 25.

The `zig` compiler detects that we are trying to change
Expand All @@ -557,7 +557,7 @@ change the value of this object how many times you want over future points
in your source code.

So, using the same code example exposed above, if I change the declaration of the
`age` object to use the `var` keyword, then, the program gets compiled succesfully.
`age` object to use the `var` keyword, then, the program gets compiled successfully.
Because now, the `zig` compiler detects that we are changing the value of an
object that allows this behaviour, because it is an "variable object".

Expand Down Expand Up @@ -641,7 +641,7 @@ When you assign an object to a underscore, like in the example below, the `zig`
discard the value of this particular object.

You can see in the example below that, this time, the compiler did not
complain about any "unused constant", and succesfully compiled our source code.
complain about any "unused constant", and successfully compiled our source code.

```{zig}
#| auto_main: true
Expand Down
2 changes: 1 addition & 1 deletion Chapters/03-structs.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ try std.testing.expect(i == 10);
try stdout.print("Everything worked!", .{});
```

Since this code example was executed succesfully by the `zig` compiler,
Since this code example was executed successfully by the `zig` compiler,
without raising any errors, then, we known that, after the execution of while loop,
the `i` object is equal to 10. Because if it wasn't equal to 10, then, an error would
be raised by `expect()`.
Expand Down
4 changes: 2 additions & 2 deletions Chapters/04-http-server.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ content back to us. It can be any type of content. It can be a web page,
a document file, or some data in a JSON format.

When a client sends a POST HTTP Request, the HTTP Response sent by the server normally have the sole purpose of
letting the client know if the server processed and stored the data succesfully.
letting the client know if the server processed and stored the data successfully.
In contrast, when the server receives a GET HTTP Request, then, the server sends the content
that the client asked for in the HTTP Response itself. This demonstrates that the method associated
with the HTTP Request changes a lot on the dynamics and the roles that each party
Expand Down Expand Up @@ -1028,7 +1028,7 @@ see the effects of these last changes. First, I execute the program once again,
Then, I open my web browser, and try to connect to the server again, using the URL `localhost:3490`.
This time, instead of getting some sort of an error message from the browser, you will get the message
"Hello World" printed into your web browser. Because this time, the server sended the HTTP Response
succesfully to the web browser, as demonstrated by @fig-print-zigrun3.
successfully to the web browser, as demonstrated by @fig-print-zigrun3.


![The Hello World message sent in the HTTP Response](./../Figures/print-zigrun3.png){#fig-print-zigrun3}
Expand Down
2 changes: 1 addition & 1 deletion Chapters/05-pointers.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ p.zig:6:12: error: cannot assign to constant
```

If I change the `number` object to be a variable object, by introducing the `var` keyword,
then, I can succesfully change the value of this object through a pointer, as demonstrated below:
then, I can successfully change the value of this object through a pointer, as demonstrated below:

```{zig}
#| auto_main: true
Expand Down
6 changes: 3 additions & 3 deletions Chapters/09-data-structures.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ pub fn main() !void {
if (hash_table.remove(57709)) {
std.debug.print(
"Value at key 57709 succesfully removed!\n",
"Value at key 57709 successfully removed!\n",
.{}
);
}
Expand All @@ -441,7 +441,7 @@ pub fn main() !void {
```
N of values stored: 3
Value at key 50050: 55
Value at key 57709 succesfully removed!
Value at key 57709 successfully removed!
N of values stored: 2
```

Expand All @@ -458,7 +458,7 @@ and that is why we use the `?` method at the end to get access to the actual val
Also notice that we can remove (or delete) values from a hashtables by using the `remove()` method.
You provide the key that identifies the value that you want to delete, then, the method will
delete this value and return a `true` value as output. This `true` value essentially tells us
that the method succesfully deleted the value.
that the method successfully deleted the value.

But this delete operation might not be always successful. For example, you might provide the wrong
key to this method. I mean, maybe you provide
Expand Down
Loading

0 comments on commit 95e5786

Please sign in to comment.