1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fixed size array with const size: numbers := [N]int

This commit is contained in:
Alexander Medvednikov
2019-08-04 03:59:12 +02:00
parent f306fbb2f0
commit 576192949d
2 changed files with 30 additions and 1 deletions

View File

@@ -160,3 +160,20 @@ fn test_reverse() {
assert d[i] == b[b.len-i-1]
}
}
const (
N = 5
)
fn test_fixed() {
mut nums := [4]int
assert nums[0] == 0
assert nums[1] == 0
assert nums[2] == 0
assert nums[3] == 0
nums[1] = 7
assert nums[1] == 7
///////
nums2 := [N]int
assert nums2[N - 1] == 0
}