V coding style coming from JS/Deno #21034
-
Hello guys, As I have mentioned elsewhere, I have rewritten all my scripts from JS/Deno to V—and it was a phantastic experience. Now I have a question about the coding style. The script in question should be split into small functions, yet it is not big enough to split it into modules and files. It reads encrypted files into an array and writes them into a CSV file:
Is this the preferred V coding style for using variables across functions, or would you suggest using global variables, Thanks a lot! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
V doesn't recommend globals at all. While you can have them, they require both an extra keyword and a command line switch to enable them. What you have will work fine, but V supports the idea of methods which can be used to modify struct values, so you don't have to pass the struct around to all the functions. |
Beta Was this translation helpful? Give feedback.
V doesn't recommend globals at all. While you can have them, they require both an extra keyword and a command line switch to enable them.
What you have will work fine, but V supports the idea of methods which can be used to modify struct values, so you don't have to pass the struct around to all the functions.