docs: more styling fixes

pull/4852/head^2
Alexander Medvednikov 2020-05-11 20:25:48 +02:00 committed by GitHub
parent 0a89aa0044
commit fd71093a28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 9 deletions

View File

@ -18,12 +18,12 @@ you can do in V.
<table>
<tr>
<td><a href='#hello-world'>1. Hello world</a></td>
<td><a href='#comments'>2. Comments</a></td>
<td><a href='#functions'>3. Functions</a></td>
<td><a href='#constants--variables'>4. Variables</a></td>
<td><a href='#primitive-types'>5. Primitive types</a></td>
<td><a href='#strings'>6. Strings</a></td>
<td width=16%><a href='#hello-world'>1. Hello world</a></td>
<td width=16%><a href='#comments'>2. Comments</a></td>
<td width=16%><a href='#functions'>3. Functions</a></td>
<td width=16%><a href='#variables'>4. Variables</a></td>
<td width=16%><a href='#primitive-types'>5. Primitive types</a></td>
<td width=16%><a href='#strings'>6. Strings</a></td>
</tr>
<tr>
<td><a href='#imports'>7. Imports</a></td>
@ -39,7 +39,7 @@ you can do in V.
<td><a href='#access-modifiers'>Access modifiers</a></td>
<td><a href='#methods'>Methods</a></td>
<td><a href='#pure-functions-by-default'>Pure functions by default</a></td>
<td><a href='#anonymous--high-order-functions'>Anonymous & high order functions</a></td>
<td><a href='#anonymous--high-order-functions'>Anonymous & high order fns</a></td>
</tr>
<tr>
<td><a href='#references'>References</a></td>
@ -51,7 +51,7 @@ you can do in V.
</tr>
<tr>
<td><a href='#sum-types'>Sum types</a></td>
<td><a href='#optionresult-types-and-error-handtdng'>Option/Result & error handling</a></td>
<td><a href='#optionresult-types-and-error-handling'>Option/Result & error handling</a></td>
<td><a href='#generics'>Generics</a></td>
<td><a href='#concurrency'>Concurrency</a></td>
<td><a href='#decoding-json'>Decoding JSON</a></td>
@ -177,7 +177,7 @@ Like constants and types, functions are private (not exported) by default.
To allow other modules to use them, prepend `pub`. The same applies
to constants and types.
## Constants & variables
## Variables
```v
name := 'Bob'
@ -200,6 +200,8 @@ type `T`.
Unlike most other languages, V only allows defining variables in functions.
Global (module level) variables are not allowed. There's no global state in V.
<p>&nbsp;</p>
```v
mut age := 20
println(age)
@ -215,6 +217,8 @@ Try compiling the program above after removing `mut` from the first line.
Note the (important) difference between `:=` and `=`
`:=` is used for declaring and initializing, `=` is used for assigning.
<p>&nbsp;</p>
```v
fn main() {
age = 21
@ -224,6 +228,8 @@ fn main() {
This code will not compile, because the variable `age` is not declared.
All variables need to be declared in V.
<p>&nbsp;</p>
```v
fn main() {
age := 21
@ -233,6 +239,8 @@ fn main() {
In development mode the compiler will warn you that you haven't used the variable (you'll get an "unused variable" warning).
In production mode (enabled by passing the `-prod` flag to v `v -prod foo.v`) it will not compile at all (like in Go).
<p>&nbsp;</p>
```v
fn main() {
a := 10