Gitly
English
Русский
Español
日本語
中文
Português
Log in
Register
v
/
vlib
/
v2
/
tests
/
module_mut_example
/
state
/
state.vv2
19
lines
·
16
sloc
·
233 bytes
·
20eada7233525573d6471d2cc70fa501213e430a
Raw
1
module state
2
3
pub struct Counter {
4
pub module_mut:
5
value int
6
pub mut:
7
label string
8
}
9
10
pub fn new_counter(label string) Counter {
11
return Counter{
12
label: label
13
}
14
}
15
16
pub fn (mut c Counter) inc() int {
17
c.value++
18
return c.value
19
}
20