diff options
author | Dave Gauer <dave@ratfactor.com> | 2021-05-03 16:58:41 -0400 |
---|---|---|
committer | Dave Gauer <dave@ratfactor.com> | 2021-05-03 16:58:41 -0400 |
commit | d4816adcb13a03a09141c73a35d01d1083eb7ca9 (patch) | |
tree | 04bf6c8ef50ca3ff763b4ff5bc57576c9f3feff7 /exercises/052_slices.zig | |
parent | 65226b5354b77679130073d96ec2d67458ce4b9b (diff) | |
download | ziglings-d4816adcb13a03a09141c73a35d01d1083eb7ca9.tar.gz ziglings-d4816adcb13a03a09141c73a35d01d1083eb7ca9.tar.bz2 ziglings-d4816adcb13a03a09141c73a35d01d1083eb7ca9.tar.xz ziglings-d4816adcb13a03a09141c73a35d01d1083eb7ca9.zip |
improve wording of 052
Diffstat (limited to 'exercises/052_slices.zig')
-rw-r--r-- | exercises/052_slices.zig | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/exercises/052_slices.zig b/exercises/052_slices.zig index 98177cd..05abe8d 100644 --- a/exercises/052_slices.zig +++ b/exercises/052_slices.zig @@ -17,11 +17,12 @@ // // const foo = digits[0..1]; // 0 // 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 // -// As you can see, a slice [x..y] defines a first item by index x and -// a length y (where y-1 is the index of the last item). Leaving y off -// gives you the rest of the items. +// As you can see, a slice [x..y] starts with the index of the +// first item at x and the last item at y-1. You can leave the y +// off to get "the rest of the items". // // 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}); } } +// +// Fun fact: Under the hood, slices are stored as a pointer to +// the first item and a length. |