cast icon indicating copy to clipboard operation
cast copied to clipboard

"ToStringSlice" does not support slice of ints?

Open danawoodman opened this issue 5 years ago • 0 comments

I was hoping that ToStringSlice would support turning a slice of ints into a slice of strings. Am I wrong in that assumption?

The following fails:

nums := []int{1,2,3,4,5}
out := cast.ToStringSlice(nums)
// expected: []string{"1","2","3","4","5"}
// actual: []

If I use ToStringSliceE I get the error:

unable to cast []int{1, 2, 3, 4, 5} of type []int to []string

Is there a cast method that does what I want that I'm not aware of?

danawoodman avatar Nov 13 '19 18:11 danawoodman