struct Point x int y int
fn (p Point) distance() f64 return f64(p.x * p.x + p.y * p.y).sqrt()
You can define methods on structs using a receiver. getting started with v programming pdf updated
fn (u User) greet() string
return 'Hello, $u.name!'
fn main()
user := Username: 'Bob', age: 25
println(user.greet())
name := 'Alice' // immutable
mut age := 30 // mutable
age = 31