when the list value involved in an insert or append operations (directly) comes from a variable, that variable receives the result list

This commit is contained in:
2024-05-19 01:42:15 +02:00
parent 24a25bbf94
commit a543360151
3 changed files with 41 additions and 15 deletions
+15 -15
View File
@@ -12,6 +12,21 @@ import (
type ListType []any
func newListA(listAny ...any) (list *ListType) {
return newList(listAny)
}
func newList(listAny []any) (list *ListType) {
if listAny != nil {
ls := make(ListType, len(listAny))
for i, item := range listAny {
ls[i] = item
}
list = &ls
}
return
}
func (ls *ListType) ToString(opt FmtOpt) string {
var sb strings.Builder
sb.WriteByte('[')
@@ -47,21 +62,6 @@ func (ls *ListType) String() string {
return ls.ToString(0)
}
func newListA(listAny ...any) (list *ListType) {
return newList(listAny)
}
func newList(listAny []any) (list *ListType) {
if listAny != nil {
ls := make(ListType, len(listAny))
for i, item := range listAny {
ls[i] = item
}
list = &ls
}
return
}
func (list *ListType) indexDeepCmp(target any) (index int) {
index = -1
for i, item := range *list {