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

fix mutable array args

This commit is contained in:
Alexander Medvednikov
2019-07-24 13:04:57 +02:00
parent 32aae80a64
commit 7ea688aa43
3 changed files with 34 additions and 19 deletions

View File

@ -63,6 +63,24 @@ fn myprint(s string, ..) {
println('/* /* comment */ */')
}
fn modify_array(a mut []int) {
a[0] = 10
for i in 0..a.len {
a[i] = a[i] * 2
}
a << 888
}
fn test_mut() {
mut nums := [1, 2, 3]
modify_array(mut nums)
assert nums.len == 4
assert nums[0] == 20
assert nums[1] == 4
assert nums[2] == 6
assert nums[3] == 888
}
fn test_fns() {
// no asserts for now, just test function declarations above
}