Saturday, December 14, 2024
HomeGolangSwap Query (sorry so easy) - Getting Assist

Swap Query (sorry so easy) – Getting Assist


My query is why does this work:

swap {
    case cfg.PlayNew.TreeReportingOptions.Sort == "very slim":
        treeMoveWidth = 1
    case cfg.PlayNew.TreeReportingOptions.Sort == "slim":
        treeMoveWidth = 3
    case cfg.PlayNew.TreeReportingOptions.Sort == "common":
        treeMoveWidth = 8

    }

BUT this doesn’t??? Observe: cfg.PlayNew.TreeReportingOptions.Sort is a string

swap cfg.PlayNew.TreeReportingOptions.Sort {
    case "very slim":
        treeMoveWidth = 1
    case "slim":
        treeMoveWidth = 3
    case "common":
        treeMoveWidth = 8

    }

Thanks in your time!

The second instance ought to be working high quality. This:

func most important() {
	treeMoveWidth := 0
	treeReportingOptionsType := "slim"
	swap treeReportingOptionsType {
	case "very slim":
		treeMoveWidth = 1
	case "slim":
		treeMoveWidth = 3
	case "common":
		treeMoveWidth = 8
	}
	fmt.Println("treeMoveWidth =", treeMoveWidth)
}

… prints the next:

treeMoveWidth = 3

You may run it your self on the playground.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments