mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
31 lines
570 B
Plaintext
31 lines
570 B
Plaintext
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===
|
|
cannot modify immutable field `len` (type `string`)
|
|
declare the field with `mut:`
|
|
struct string {
|
|
mut:
|
|
len int
|
|
}
|
|
cannot modify immutable field `len` (type `array`)
|
|
declare the field with `mut:`
|
|
struct array {
|
|
mut:
|
|
len int
|
|
}
|
|
cannot modify immutable field `len` (type `array`)
|
|
declare the field with `mut:`
|
|
struct array {
|
|
mut:
|
|
len int
|
|
}
|
|
BYE
|