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-11-13 20:39:58 +03:00
|
|
|
cannot modify immutable field `len` (type `string`)
|
2019-09-16 00:41:12 +03:00
|
|
|
declare the field with `mut:`
|
|
|
|
struct string {
|
2019-12-18 04:59:42 +03:00
|
|
|
mut:
|
2019-09-16 00:41:12 +03:00
|
|
|
len int
|
|
|
|
}
|
2019-11-13 20:39:58 +03:00
|
|
|
cannot modify immutable field `len` (type `array`)
|
2019-09-16 00:41:12 +03:00
|
|
|
declare the field with `mut:`
|
|
|
|
struct array {
|
2019-12-18 04:59:42 +03:00
|
|
|
mut:
|
2019-09-16 00:41:12 +03:00
|
|
|
len int
|
|
|
|
}
|
2019-11-13 20:39:58 +03:00
|
|
|
cannot modify immutable field `len` (type `array`)
|
2019-09-16 00:41:12 +03:00
|
|
|
declare the field with `mut:`
|
|
|
|
struct array {
|
2019-12-18 04:59:42 +03:00
|
|
|
mut:
|
2019-09-16 00:41:12 +03:00
|
|
|
len int
|
|
|
|
}
|
|
|
|
BYE
|