Sobeston / zig.guide

Repo for https://zig.guide content. Get up to speed with Zig quickly.
https://zig.guide
MIT License
647 stars 170 forks source link

Local variable is never mutated #244

Closed chikoYEAT closed 2 months ago

chikoYEAT commented 2 months ago

Changed var index to const index: Since local variable is never muted

test "out of bounds" { const a = [3]u8{ 1, 2, 3 }; const index: u8 = 5; const b = a[index]; _ = b; }

test "out of bounds, no safety" { @setRuntimeSafety(false); const a = [3]u8{ 1, 2, 3 }; const index: u8 = 5; const b = a[index]; _ = b; }

image