Variable declaration reset: Difference between revisions

Content added Content deleted
m (syntax highlighting fixup automation)
(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
Line 696: Line 696:
</pre>
</pre>


=={{header|Vlang}}==
=={{header|V (Vlang)}}==
Note firstly that unassigned variables are impossible in Vlang. If a variable is created it must have an explicit value, then it is assigned the default value for its type which in the case of numbers is zero. Fortunately, this doesn't clash with values in the slice in the following program.
Note firstly that unassigned variables are impossible in Vlang. If a variable is created it must have an explicit value, then it is assigned the default value for its type which in the case of numbers is zero. Fortunately, this doesn't clash with values in the slice in the following program.
<syntaxhighlight lang="vlang">fn main() {
<syntaxhighlight lang="v (vlang)">fn main() {
s := [1, 2, 2, 3, 4, 4, 5]
s := [1, 2, 2, 3, 4, 4, 5]