switch v.(type) could eliminate type assertions in switch cases
switch v := v.(type) {
case int:
m[k] = v * 2
case string:
m[k] = goStrings.Repeat(v, 2)
default:
}
最后发现居然在获取类型的时候会自动转掉,不得不说很贴心了 QAQ,果然码农最懂码农需要什么
switch v.(type) could eliminate type assertions in switch cases
switch v := v.(type) {
case int:
m[k] = v * 2
case string:
m[k] = goStrings.Repeat(v, 2)
default:
}
最后发现居然在获取类型的时候会自动转掉,不得不说很贴心了 QAQ,果然码农最懂码农需要什么