Skip to content

Commit

Permalink
⏪ up: arrutil - revert the ToString handle logic
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jul 17, 2023
1 parent 06b9b37 commit c553460
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
9 changes: 2 additions & 7 deletions arrutil/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,8 @@ func AnyToString(arr any) string {
// SliceToString convert []any to string
func SliceToString(arr ...any) string { return ToString(arr) }

// ToString simple and quickly convert []any to string
func ToString(arr []any) string {
return TString[any](arr)
}

// TString simple and quickly convert []T to string
func TString[T any](arr []T) string {
// ToString simple and quickly convert []T to string
func ToString[T any](arr []T) string {
// like fmt.Println([]any(nil))
if arr == nil {
return "[]"
Expand Down
3 changes: 0 additions & 3 deletions arrutil/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ func TestAnyToString(t *testing.T) {

func TestSliceToString(t *testing.T) {
is := assert.New(t)

is.Eq("[]", arrutil.SliceToString(nil))
is.Eq("[]", arrutil.TString[any](nil))
is.Eq("[a,b]", arrutil.TString([]string{"a", "b"}))

is.Eq("[]", arrutil.ToString(nil))
is.Eq("[a,b]", arrutil.ToString([]any{"a", "b"}))
Expand Down
4 changes: 2 additions & 2 deletions arrutil/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Ints[T comdef.Integer] []T

// String to string
func (is Ints[T]) String() string {
return TString(is)
return ToString(is)
}

// Has given element
Expand Down Expand Up @@ -151,7 +151,7 @@ func (ls SortedList[T]) IsEmpty() bool {

// String to string
func (ls SortedList[T]) String() string {
return TString(ls)
return ToString(ls)
}

// Has given element
Expand Down

0 comments on commit c553460

Please sign in to comment.