v/vlib/compiler/tests/repl/immutable_len_fields/fields.1.repl

12 lines
203 B
Plaintext

mut s := 'hello world'
s.len = 0 // Error (field len immutable)
'BYE'
===output===
cannot modify immutable field `len` (type `string`)
declare the field with `mut:`
struct string {
mut:
len int
}
BYE