亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

http://tour.golang.org/methods/11 的解決方案

http://tour.golang.org/methods/11 的解決方案

Go
守候你守候我 2021-09-10 17:35:27
實現一個 Reader 類型,它發出 ASCII 字符“A”的無限流。我不明白這個問題,如何發出字符“A”?我應該將該字符設置為哪個變量?這是我嘗試過的:package mainimport "code.google.com/p/go-tour/reader"type MyReader struct{}// TODO: Add a Read([]byte) (int, error) method to MyReader.func (m MyReader) Read(b []byte) (i int, e error) {    b = append(b,'A') // this is wrong..    return 1, nil // this is also wrong..}func main() {    reader.Validate(MyReader{}) // what did this function expect?}
查看完整描述

2 回答

?
HUH函數

TA貢獻1836條經驗 獲得超4個贊

即使沒有拼寫錯誤,所謂的答案對我也不起作用。像我一樣嘗試,該字符串不會進入 b。


func (r MyReader) Read(b []byte) (int,  error) {

    return copy(b, "A"), nil

}


查看完整回答
反對 回復 2021-09-10
  • 2 回答
  • 0 關注
  • 187 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號