new operator ':=', it assigns a value to a variable by deep copy

This commit is contained in:
2026-05-17 05:02:07 +02:00
parent 08617378e0
commit 0c719025cd
9 changed files with 201 additions and 198 deletions
+28
View File
@@ -0,0 +1,28 @@
// Copyright (c) 2024-2026 Celestino Amoroso (celestino.amoroso@gmail.com).
// All rights reserved.
// clone-value.go
package kern
func Clone(v any) (c any) {
if v == nil {
return
}
switch unboxed := v.(type) {
case int64:
c = unboxed
case float64:
c = unboxed
case string:
c = unboxed
case bool:
c = unboxed
case *ListType:
c = unboxed.Clone()
case *DictType:
c = unboxed.Clone()
default:
c = v
}
return
}