improve wording of 052

This commit is contained in:
Dave Gauer 2021-05-03 16:58:41 -04:00
parent 4760c62d62
commit 1b7155b11d

View file

@ -17,11 +17,12 @@
// //
// const foo = digits[0..1]; // 0 // const foo = digits[0..1]; // 0
// const bar = digits[3..9]; // 3 4 5 6 7 8 // const bar = digits[3..9]; // 3 4 5 6 7 8
// const bar = digits[5..9]; // 5 6 7 8
// const all = digits[0..]; // 0 1 2 3 4 5 6 7 8 9 // const all = digits[0..]; // 0 1 2 3 4 5 6 7 8 9
// //
// As you can see, a slice [x..y] defines a first item by index x and // As you can see, a slice [x..y] starts with the index of the
// a length y (where y-1 is the index of the last item). Leaving y off // first item at x and the last item at y-1. You can leave the y
// gives you the rest of the items. // off to get "the rest of the items".
// //
// Notice that the type of a slice on an array of u8 items is []u8. // Notice that the type of a slice on an array of u8 items is []u8.
// //
@ -47,3 +48,6 @@ fn printHand(hand: ???) void {
std.debug.print("{u} ", .{h}); std.debug.print("{u} ", .{h});
} }
} }
//
// Fun fact: Under the hood, slices are stored as a pointer to
// the first item and a length.