Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
9
Task/Special-variables/V-(Vlang)/special-variables-1.v
Normal file
9
Task/Special-variables/V-(Vlang)/special-variables-1.v
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// function that returns multiple values
|
||||
fn foo() (int, int) {
|
||||
return 2, 3
|
||||
}
|
||||
|
||||
mut a, mut b := foo()
|
||||
println("${a} and ${b}")
|
||||
a, _ = foo() // to ignore particular returned values, use `_`
|
||||
println(a)
|
||||
9
Task/Special-variables/V-(Vlang)/special-variables-2.v
Normal file
9
Task/Special-variables/V-(Vlang)/special-variables-2.v
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// ignore values, while iterating over keys
|
||||
m := {
|
||||
'one': 1
|
||||
'two': 2
|
||||
}
|
||||
|
||||
for key, _ in m {
|
||||
println(key)
|
||||
}
|
||||
4
Task/Special-variables/V-(Vlang)/special-variables-3.v
Normal file
4
Task/Special-variables/V-(Vlang)/special-variables-3.v
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
// "it", used in filter and map
|
||||
nums := [1, 2, 3, 4, 5, 6]
|
||||
even := nums.filter(it % 2 == 0)
|
||||
println(even)
|
||||
6
Task/Special-variables/V-(Vlang)/special-variables-4.v
Normal file
6
Task/Special-variables/V-(Vlang)/special-variables-4.v
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// "a" and "b" in sorting arrays, used to provide custom sorting conditions
|
||||
mut numbers := [1, 3, 2]
|
||||
numbers.sort()
|
||||
println(numbers)
|
||||
numbers.sort(a > b) // reverse sort
|
||||
println(numbers)
|
||||
Loading…
Add table
Add a link
Reference in a new issue