Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upexample in document not work in playground #3043
Comments
This comment has been minimized.
This comment has been minimized.
|
Following code works, the cause is enum Color {
red green blue
}
fn main() {
mut color := Color.red
// V knows that `color` is a `Color`. No need to use `color = Color.green` here.
color = .green
println(color) // "1" TODO: print "green"?
} |
This comment has been minimized.
This comment has been minimized.
|
@vuhg so it is bad error message. I do not know why it is not working... |
This comment has been minimized.
This comment has been minimized.
|
@medvednikov The above screened behavior seems a bit odd. It's not documented that enums have to be declared outside of functions. I tried some other stuff and declared some enums within a bunch of functions (this time not within main) and get a similar error. Although I did this (declaring them 'standalone') naturally and never thought about this, they are just some kinds of variables aren't they? So one should be able to do the above declaration style. That would limit their scope too - besides pub enum declaration. I personally think it's a documentation issue to clarify the use of them. |
V version:
OS:
https://vlang.io/play
What did you do?
errorMessage: