mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
docs: fix v check-md .
on macos
This commit is contained in:
parent
db194abeac
commit
403da9f36e
@ -2117,7 +2117,7 @@ They must do so explicitly by listing all variables that are inherited.
|
||||
> Warning: currently works on Unix-based, x64 architectures only.
|
||||
Some work is in progress to make closures work on Windows, then other architectures.
|
||||
|
||||
```v
|
||||
```v oksyntax
|
||||
my_int := 1
|
||||
my_closure := fn [my_int] () {
|
||||
println(my_int)
|
||||
@ -2129,7 +2129,7 @@ Inherited variables are copied when the anonymous function is created.
|
||||
This means that if the original variable is modified after the creation of the function,
|
||||
the modification won't be reflected in the function.
|
||||
|
||||
```v
|
||||
```v oksyntax
|
||||
mut i := 1
|
||||
func := fn [i] () int {
|
||||
return i
|
||||
@ -2142,7 +2142,7 @@ println(func() == 1) // still true
|
||||
However, the variable can be modified inside the anonymous function.
|
||||
The change won't be reflected outside, but will be in the later function calls.
|
||||
|
||||
```v
|
||||
```v oksyntax
|
||||
fn new_counter() fn () int {
|
||||
mut i := 0
|
||||
return fn [mut i] () int {
|
||||
@ -2161,7 +2161,7 @@ If you need the value to be modified outside the function, use a reference.
|
||||
**Warning**: _you need to make sure the reference is always valid,
|
||||
otherwise this can result in undefined behavior._
|
||||
|
||||
```v
|
||||
```v oksyntax
|
||||
mut i := 0
|
||||
mut ref := &i
|
||||
print_counter := fn [ref] () {
|
||||
|
Loading…
Reference in New Issue
Block a user