2019-09-16 00:41:12 +03:00
|
|
|
mut s := 'hello world'
|
|
|
|
s.len = 0 // Error (field len immutable)
|
|
|
|
|
|
|
|
mut a := []string
|
|
|
|
a.len = 0 // Error (field len immutable)
|
|
|
|
|
|
|
|
mut ints := []int
|
|
|
|
ints.len = 0 // Error (field len immutable)
|
|
|
|
|
|
|
|
println('BYE')
|
|
|
|
===output===
|
2019-10-06 17:21:10 +03:00
|
|
|
.vrepl_temp.v:3:5: cannot modify immutable field `len` (type `string`)
|
2019-09-16 00:41:12 +03:00
|
|
|
declare the field with `mut:`
|
|
|
|
struct string {
|
|
|
|
mut:
|
|
|
|
len int
|
|
|
|
}
|
2019-10-06 17:21:10 +03:00
|
|
|
.vrepl_temp.v:4:5: cannot modify immutable field `len` (type `array`)
|
2019-09-16 00:41:12 +03:00
|
|
|
declare the field with `mut:`
|
|
|
|
struct array {
|
|
|
|
mut:
|
|
|
|
len int
|
|
|
|
}
|
2019-10-06 17:21:10 +03:00
|
|
|
.vrepl_temp.v:5:8: cannot modify immutable field `len` (type `array`)
|
2019-09-16 00:41:12 +03:00
|
|
|
declare the field with `mut:`
|
|
|
|
struct array {
|
|
|
|
mut:
|
|
|
|
len int
|
|
|
|
}
|
|
|
|
BYE
|