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

@@ -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
}