Commit 1d5368fa35

Manlio Perillo <manlio.perillo@gmail.com>
2022-12-08 14:34:43
langref: fix the slice_bounds.zig doctest
In the slice_bounds.zig doctest, the code "const slice = array[2..4]" is incorrect, since the actual type is a pointer to an array, instead of a slice. Use a runtime know value to slice the array.
1 parent 21dafd7
Changed files (1)
doc/langref.html.in
@@ -2691,7 +2691,8 @@ const expect = @import("std").testing.expect;
 
 test "pointer slicing" {
     var array = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
-    const slice = array[2..4];
+    var start: usize = 2;
+    const slice = array[start..4];
     try expect(slice.len == 2);
 
     try expect(array[3] == 4);