mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
20 lines
357 B
V
20 lines
357 B
V
struct Human { name string }
|
|
|
|
pub fn (h Human) str() string { return 'Human: $h.name' }
|
|
|
|
type Person Human
|
|
|
|
fn test_type_print() {
|
|
p := Person{'Bilbo'}
|
|
println(p)
|
|
assert p.str() == 'Human: Bilbo'
|
|
}
|
|
|
|
pub fn (h Person) str() string { return 'Person: $h.name' }
|
|
|
|
fn test_person_str() {
|
|
p := Person{'Bilbo'}
|
|
println(p)
|
|
assert p.str() == 'Person: Bilbo'
|
|
}
|