当前位置:网站首页>June 21, 2022: golang multiple choice question, what does the following golang code output? A:3; B:4; C:100; D: Compilation failed. package main import ( “fmt“ ) func

June 21, 2022: golang multiple choice question, what does the following golang code output? A:3; B:4; C:100; D: Compilation failed. package main import ( “fmt“ ) func

2022-06-22 06:52:00 Fuda scaffold constructor's daily question

2022-06-21:golang choice question , following golang What does the code output ?A:3;B:4;C:100;D: Compile failed .

package main

import (
	"fmt"
)

func main() {
    
	m := [...]int{
    
		'a': 1,
		'b': 2,
		'c': 3,
	}
	m['a'] = 3
	fmt.Println(len(m))
}

answer 2022-06-21:

Answer selection C. The reason is that ’c’ Of ASCII The value of is 99, Slice indices 99, Slice length must be 100 And above .

The operation results are as follows :

 Insert picture description here

原网站

版权声明
本文为[Fuda scaffold constructor's daily question]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220650367483.html