arrays: use for/in instead of unsafe [direct_array_access] (#8857)

This commit is contained in:
Nick Treleaven 2021-02-20 13:27:36 +00:00 committed by GitHub
parent 38d1eac7f5
commit 2be852e461
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 41 deletions

View file

@ -1,7 +1,5 @@
module arrays
import rand
fn test_min() {
a := [8, 2, 6, 4]
assert min<int>(a) == 2
@ -54,24 +52,3 @@ fn test_merge() {
assert merge<int>(a, c) == a
assert merge<int>(d, b) == b
}
fn test_fixed_array_assignment() {
mut a := [2]int{}
a[0] = 111
a[1] = 222
b := a
assert b[0] == a[0]
assert b[1] == a[1]
mut c := [2]int{}
c = a
assert c[0] == a[0]
assert c[1] == a[1]
d := [3]int{init: 333}
for val in d {
assert val == 333
}
e := [3]string{init: 'vlang'}
for val in e {
assert val == 'vlang'
}
}