41 lines
585 B
V
41 lines
585 B
V
struct User {
|
|
a int
|
|
b int
|
|
}
|
|
|
|
struct Foo {
|
|
a int
|
|
b int
|
|
}
|
|
|
|
fn (u User) + () {
|
|
}
|
|
|
|
fn (u User) - (f Foo) User {
|
|
return User{u.a - f.a, u.b-f.a}
|
|
}
|
|
|
|
fn (mut u User) * (u1 User) User {
|
|
return User{}
|
|
}
|
|
|
|
fn (u User) / (mut u1 User) User {
|
|
return User{}
|
|
}
|
|
|
|
fn (u User) + (u1 User) Foo {
|
|
return Foo{a: u.a + u1.a, b: u.b + u1.b}
|
|
}
|
|
|
|
fn main() {
|
|
println(User{3, 4})
|
|
println(User{3, 4} - Foo{3, 3})
|
|
println(User{3, 2} < User{2, 4})
|
|
println(User{3, 4} < Foo{3, 4})
|
|
mut u := User{3, 4}
|
|
_ = u
|
|
u += 12
|
|
u %= User{1, 3}
|
|
u += User{2, 3}
|
|
}
|