Add generic and generic structs

This commit is contained in:
Archie Fox
2025-03-14 17:50:02 +03:00
parent e7bb6ba60a
commit 6da4edff07
2 changed files with 13 additions and 0 deletions

View File

@@ -10,6 +10,9 @@ import (
)
func main() {
// fmt.Println(output.Sum(100, 42))
// fmt.Println(output.Sum(10.7, 3.14))
// fmt.Println(output.Sum("Hello ", "world!"))
fmt.Println("__Менеджер паролей__")
vault := account.NewVault(files.NewJsonDb("data.json"))
Menu:

View File

@@ -14,3 +14,13 @@ func PrintError(value any) {
color.Red("Неизвестный тип ошибки")
}
}
// Generic
func Sum[T int | float32 | float64 | string](a, b T) T {
return a + b
}
// Generic structs
type List[T any] struct {
elements []T
}