一直弄不懂 .(type) 是啥,在 liteide 中輸出 (1+1).(type),提示:ide
use of .(type) outside type switch.net
做者:翔雲翔雲
來源:CSDN
原文:https://blog.csdn.net/lanyang123456/article/details/78070886
版權聲明:本文爲博主原創文章,轉載請附上博文連接!code
package main import ( "fmt" ) func main() { CheckType("tow", 88, "three") } func CheckType(args ...interface{}) { for _,v := range args { switch v.(type) { case int: fmt.Println("type:int, value:", v) case string: fmt.Println("type:string, value:", v) default: fmt.Println("type:unkown,value:",v) } } }
2019/01/02補:
昨天看書看到這個叫類型斷言
blog