mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
gen: implement type_name method for sum type instances (#6802)
This commit is contained in:
@ -1634,8 +1634,11 @@ struct Venus {}
|
||||
type World = Moon | Mars | Venus
|
||||
|
||||
sum := World(Moon{})
|
||||
assert sum.type_name() == 'Moon'
|
||||
println(sum)
|
||||
```
|
||||
The built-in method `type_name` returns the name of the currently held
|
||||
type.
|
||||
|
||||
#### Dynamic casts
|
||||
|
||||
|
Reference in New Issue
Block a user