mut array as parameter
fn print_array(array mut []int) {
for n in array {
println(n)
}
}
fn main() {
mut array := [1, 2, 34]
print_array(mut array)
}
Output:
You just found a bug. V can't compile this program, but it should. Please create a GitHub issue.
Without 'mut' it works as expected.
Mutable arguments are a recent addition, and I think it's clear I don't use them at all in my code :)
Will fix after the release.
In the future V should actually not compile this example because array is not modified at all.
In the future V should actually not compile this example because
arrayis not modified at all.
Does it means that i should return a new array if i want modify array?
For now yes, until the bug is fixed.
I think it's clear I don't use them at all in my code :)
Does it mean V has no tests even for basic features?
No it doesn't. But there definitely should be more tests.
Tests have been made and are in active development. The original issue still doesn't work, but that can be discussed in the new issue #652.