mirror of
https://github.com/ziglang/zig.git
synced 2024-11-14 16:13:24 +00:00
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.
This commit is contained in:
parent
21dafd7a54
commit
1d5368fa35
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user