是否可以在boolInt不重新定義的情況下為函數(shù)創(chuàng)建通道?package mainfunc boolInt() (bool, int) { return false, 1}func main() { chanBool := make(chan bool) chanInt := make(chan int) go func() { // chanBool <- boolInt() // error: multiple-value boolInt() in single-value context chanBool, chanInt <- boolInt() // syntax error: unexpected semicolon or newline, expecting := or = or comma }()}當(dāng)我嘗試在單值上下文中使用它 chanBool <- boolInt(),我得到一個(gè)錯(cuò)誤: multiple-value boolInt() in single-value context。在 2 值上下文中: chanBool, chanInt <- boolInt()得到錯(cuò)誤:syntax error: unexpected semicolon or newline, expecting := or = or comma。
- 2 回答
- 0 關(guān)注
- 203 瀏覽
添加回答
舉報(bào)
0/150
提交
取消