第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

`go`中`switch`的求值序列

`go`中`switch`的求值序列

Go
慕妹3146593 2021-11-22 16:15:27
我正在通過閱讀“Effective Go”來學習 Go 語言。我找到了一個關于類型切換的例子:var t interface{}t = functionOfSomeType()switch t := t.(type) {default:    fmt.Printf("unexpected type %T\n", t)     // %T prints whatever type t hascase bool:    fmt.Printf("boolean %t\n", t)             // t has type boolcase int:    fmt.Printf("integer %d\n", t)             // t has type intcase *bool:    fmt.Printf("pointer to boolean %t\n", *t) // t has type *boolcase *int:    fmt.Printf("pointer to integer %d\n", *t) // t has type *int}我的理解是switch從上到下評估案例并在匹配條件下停止。那么這個例子不是總是停留在default并打印“意外類型......”嗎?
查看完整描述

1 回答

?
猛跑小豬

TA貢獻1858條經驗 獲得超8個贊

這個 Golang 教程

  • default如果其他case塊都不匹配,則執(zhí)行的代碼塊

  • default塊可以是內的任何地方switch塊,而不一定是最后的詞匯順序


查看完整回答
反對 回復 2021-11-22
  • 1 回答
  • 0 關注
  • 199 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號