Skip to content

Commit dc1dcf1

Browse files
authored
Fix some typos, reword enum bit again
1 parent 62c670d commit dc1dcf1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

chapter-1.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ test "set enum ordinal value" {
590590
}
591591
```
592592

593-
Functions can be given to enums. These are sometimes called "methods", and act as namespaced functions that can be called with dot syntax. As a convenience, when called from an instance of the enum these methods are automatically passed that instance as their first argument. Notice below that `Suit.spades.isClubs()` is equivalent to `Suit.isClubs(Suit.spades)`. Additionally, since we're calling the method from the enum, we don't have to specify the enum again, and can shorten the argument to just `.spades`.
593+
Functions can be given to enums. These are sometimes called "methods", and act as namespaced functions that can be called with dot syntax. As a convenience, when called from an instance of the enum these methods are automatically passed that instance as their first argument. Thus, `Suit.spades.isClubs()` is equivalent to `Suit.isClubs(Suit.spades)`. Additionally, when calling a method from the enum, we can shorten the argument to omit the enum name and pass it with just a leading dot, as in the example below.
594594

595595
```zig
596596
const Suit = enum {
@@ -674,7 +674,7 @@ test "struct defaults" {
674674

675675
Like enums, structs may also contain functions and declarations.
676676

677-
Similar to enums, methods called from a struct instance will be passed a _pointer to_ that instance. In addition, structs an additional unique property: when accessing fields from a pointer to a struct, one level of dereferencing is done automatically. Notice how these work together in the example below: the swap() function is automatically passed a pointer to `thing`, and then accesses self.x and self.y using that pointer without needing to dereference it.
677+
Similar to enums, methods called from a struct instance will be passed a *pointer to* that instance. Structs also have an additional unique property: when accessing fields from a pointer to a struct, one level of dereferencing is done automatically. Notice how these work together in the example below: the swap() function is automatically passed a pointer to `thing`, and then accesses self.x and self.y using that pointer without needing to dereference it.
678678

679679
```zig
680680
const Stuff = struct {

0 commit comments

Comments
 (0)