Исходники и презентации

This commit is contained in:
2025-05-23 07:26:39 +03:00
parent aa948179d5
commit 02d8430a3a
514 changed files with 13773 additions and 0 deletions

View File

@ -0,0 +1,33 @@
package main
import (
"fmt"
"reflect"
)
type Vector struct {
X int
Y int
}
func (v Vector) Add(factor int) int {
return (v.X + v.Y) * factor
}
func main() {
vector := Vector{X: 5, Y: 15}
vVector := reflect.ValueOf(vector)
vAdd := vVector.MethodByName("Add")
vResults := vAdd.Call([]reflect.Value{reflect.ValueOf(2)})
fmt.Println(vResults[0].Int())
negative := func(x int) int {
return -x
}
vNegative := reflect.ValueOf(negative)
vResults = vNegative.Call([]reflect.Value{reflect.ValueOf(100)})
fmt.Println(vResults[0].Int())
}