Replies: 3 comments 4 replies
-
Try moving line 12 up to the end of line 11. |
Beta Was this translation helpful? Give feedback.
-
Notice that the error message changed. That was the point of my previous comment. The main problem with what you have is that the syntax is simply wrong. You want something more like
to return a map with string keys and i16 values. As for what types you can use as keys... that's actually in the docs, here https://github.com/vlang/v/blob/master/doc/docs.md#maps
Enums may also work... not sure. |
Beta Was this translation helpful? Give feedback.
-
Here the final code:
|
Beta Was this translation helpful? Give feedback.
-
Hi everyone
I am a newbie in V, so it is my third code in V, and already taking some difficulties with maps. Since to pass it as an argument either to return it. I want to obtain a map from :
print('\n MY map: ${creating_a_map(10)}' ) (line 28), where the code is in:
https://github.com/claudiosa/CCS/blob/master/v_programming_language/maps_study.v
but a silly and strange error came:
$ v run maps_study.v
maps_study.v:27:4: error: function declarations in script mode should be before all script statements
......
it does not make sense for me yet
In addition, whose types are supported as the keys in V for maps? Only strings? Byte? Runes?
Sorry, I did not scrap for similar questions in this discussion ....
Thanks in advance for any help.
Claudio
Beta Was this translation helpful? Give feedback.
All reactions