Gitly
English
Русский
Español
日本語
中文
Português
Pricing
Log in
Register
vxx
/
vlib
/
v2_toberemoved
/
tests
/
module_mut_example
/
state
/
state.vv2
19
lines
·
16
sloc
·
233 bytes
·
c0624b274a458fe3e487d89ae9554c2e8c25bdb6
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