About the use of slice of the slice of strings

The code is below

package main

import "fmt"

func main() {
	buckets := make([][]string, 12)
	var Str string
	for i := 0; i < 6; i++ {
		Str = Words(i)
		buckets[1] = append(buckets[1], Str)

/func Words(n int) string {
	switch n {
	case 1:
		return "one"
	case 2:
		return "two"
	case 3:
		return "three"
	case 4:
		return "four"
	case 5:
		return "five"
		return "Numbers"

The error shown in the terminal

./forfun.go:20: invalid identifier character U+FF09 ')'
./forfun.go:20: syntax error: unexpected ), expecting comma or )
./forfun.go:23: syntax error: unexpected func, expecting )

I am not sure where this is going wrong? Is it something with for loops or bcoz of the incorrect use of Switch?


because of the line 12 's (buckets[1]) ,edit the )

1 Like

After that remove this slash :slight_smile:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.