join
This commit is contained in:
10
set.go
10
set.go
@@ -1,7 +1,9 @@
|
||||
package extypes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Set[T any] []T
|
||||
@@ -108,3 +110,11 @@ func (s Set[T]) Map(f func(e T) T) Set[T] {
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s Set[T]) Join(sep string) string {
|
||||
st := make([]string, len(s))
|
||||
for i, v := range s {
|
||||
st[i] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
return strings.Join(st, sep)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user