mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
84 lines
783 B
V
84 lines
783 B
V
fn function1() int {
|
|
a := 10 + 1
|
|
b := a + 1
|
|
//return a
|
|
return 0
|
|
}
|
|
|
|
fn foo(a int) {
|
|
//end()
|
|
}
|
|
|
|
struct User {
|
|
name string
|
|
}
|
|
|
|
fn init_user() {
|
|
user := User{
|
|
name: 'Bob'
|
|
}
|
|
}
|
|
|
|
fn get_user() User {
|
|
user := User{}
|
|
return user
|
|
}
|
|
|
|
|
|
fn puts(s string) {}
|
|
|
|
// comment
|
|
fn function2() {
|
|
mut x := 0
|
|
//mut negative := -1
|
|
f := 10.1
|
|
s := 'hi'
|
|
mut m := 10
|
|
x += 10
|
|
x += 1
|
|
m += 2
|
|
function1()
|
|
// a += 1
|
|
// c := 0
|
|
if true {
|
|
foo(10)
|
|
x += 8
|
|
}
|
|
if false {
|
|
foo(1)
|
|
}
|
|
else {
|
|
puts('else')
|
|
foo(100)
|
|
}
|
|
for true {
|
|
init_user()
|
|
}
|
|
e := 1 + 2 > 0
|
|
e2 := 1 + 2 < 0
|
|
// x += 1
|
|
j := 0
|
|
}
|
|
|
|
fn init_array() {
|
|
nums := [1,2,3]
|
|
|
|
}
|
|
|
|
fn end() {
|
|
|
|
}
|
|
|
|
/*
|
|
fn bool_array() {
|
|
a := [true, false]
|
|
b := a[0]
|
|
if b {
|
|
println('ok')
|
|
}
|
|
}
|
|
*/
|
|
|
|
fn main() {
|
|
}
|