Skip to content

Commit

Permalink
fix(String): return empty array for array cast
Browse files Browse the repository at this point in the history
  • Loading branch information
alfarih31 committed Mar 5, 2022
1 parent d2117ad commit 6bfb346
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions string.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ func (s String) ToBool() (bool, error) {

// ToStringArr cast String to array of string
func (s String) ToStringArr(separator ...string) ([]string, error) {
if s == "" {
return []string{}, nil
}

sep := ","
if len(separator) > 0 {
sep = separator[0]
Expand All @@ -59,6 +63,10 @@ func (s String) ToStringArr(separator ...string) ([]string, error) {

// ToIntArr cast String to array of int
func (s String) ToIntArr(separator ...string) ([]int, error) {
if s == "" {
return []int{}, nil
}

sep := ","
if len(separator) > 0 {
sep = separator[0]
Expand Down

0 comments on commit 6bfb346

Please # to comment.