| author | |
| committer | |
| log | 1d5368fa35740f64d81f755588edc5c6698036ec |
| tree | 504aa90c5fa89a66cf677ad9cb8bdcdb061b5ddc |
| parent | 21dafd7a54f1b3233e0e73439daee82aa08d4900 |
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 files changed, 2 insertions(+), 1 deletions(-)
doc/langref.html.in+2-1| ... | ... | @@ -2691,7 +2691,8 @@ const expect = @import("std").testing.expect; |
| 2691 | 2691 | |
| 2692 | 2692 | test "pointer slicing" { |
| 2693 | 2693 | var array = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; |
| 2694 | const slice = array[2..4]; | |
| 2694 | var start: usize = 2; | |
| 2695 | const slice = array[start..4]; | |
| 2695 | 2696 | try expect(slice.len == 2); |
| 2696 | 2697 | |
| 2697 | 2698 | try expect(array[3] == 4); |