добавил возможность возвращать много значений для функций
parent
519717e3eb
commit
b243bdafad
|
@ -106,6 +106,10 @@ math_expr_or_literals_list:
|
||||||
math_expr_or_literals_list_or_empty:
|
math_expr_or_literals_list_or_empty:
|
||||||
| math_expr_or_literals_list
|
| math_expr_or_literals_list
|
||||||
|
|
||||||
|
types_list:
|
||||||
|
| type
|
||||||
|
| types_list COMMA type
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
// condition
|
// condition
|
||||||
|
@ -342,7 +346,9 @@ arg_list:
|
||||||
;
|
;
|
||||||
|
|
||||||
return_type:
|
return_type:
|
||||||
| type { }
|
| type
|
||||||
|
| LPAREN types_list RPAREN { }
|
||||||
|
| LPAREN arg_list RPAREN { }
|
||||||
;
|
;
|
||||||
|
|
||||||
func_declaration:
|
func_declaration:
|
||||||
|
|
|
@ -2,6 +2,10 @@ package main
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
|
func add(x, y int) (z, f, u int, a string) {
|
||||||
|
z = x + y
|
||||||
|
return
|
||||||
|
}
|
||||||
func main() {
|
func main() {
|
||||||
a := 1e6
|
a := 1e6
|
||||||
fmt.Println(a)
|
fmt.Println(a)
|
||||||
|
|
|
@ -2,6 +2,21 @@ package main;
|
||||||
|
|
||||||
import "fmt";
|
import "fmt";
|
||||||
|
|
||||||
|
func A(x, y int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func B(x, y int) () {
|
||||||
|
}
|
||||||
|
|
||||||
|
func C(x, y int) int {
|
||||||
|
}
|
||||||
|
|
||||||
|
func D(x, y int) (int, string) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func E(x, y int) (z, f, u int, a string) {
|
||||||
|
}
|
||||||
|
|
||||||
// анонимные функции
|
// анонимные функции
|
||||||
func anon_func(a,b,c,d string, a int) {
|
func anon_func(a,b,c,d string, a int) {
|
||||||
// Присваиваем анонимную функцию переменной
|
// Присваиваем анонимную функцию переменной
|
||||||
|
|
Loading…
Reference in New Issue