Enforced immutability: Difference between revisions

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


=={{header|Vlang}}==
=={{header|V (Vlang)}}==
In Vlang:
In V (Vlang):


1) Variables are immutable, by default.
1) Variables are immutable, by default.
Line 1,294: Line 1,294:


To change the values of variables, arguments, and struct fields the keyword "mut" is used.
To change the values of variables, arguments, and struct fields the keyword "mut" is used.
<syntaxhighlight lang="vlang">// To change the value of the variable, after making it mutable with "mut", use "=".
<syntaxhighlight lang="v (vlang)">// To change the value of the variable, after making it mutable with "mut", use "=".


mut age := 20
mut age := 20