[go-nuts] How to pass arbitrary typed (int, string, etc) slices to a golang function?

2016-09-22 Thread Dave Cheney
There are two ways, one is to use reflection, the other would be to use unsafe to convert the slice value into another structure then extract the length field. Assuming that you could write a Len function as you specified, what would you do next? What problem are you trying to solve? -- You

[go-nuts] How to pass arbitrary typed (int, string, etc) slices to a golang function?

2016-09-22 Thread Lax Clarke
How would someone create a function like len ? func Len(s []interface{}) would not work because compiler complains of type mismatch if you call it with an integer slice (for example) Thanks -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To