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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

從未使用此預(yù)訂值 (SA4006)

從未使用此預(yù)訂值 (SA4006)

Go
瀟湘沐 2022-10-24 09:56:37
我正在嘗試學(xué)習(xí) Golang,因?yàn)槲艺谂c Nana 一起使用 Techworld 在 Youtube 上做一個(gè)教程,并學(xué)習(xí)使用函數(shù)對(duì)邏輯進(jìn)行分組,它顯示了一個(gè)之前不存在的錯(cuò)誤,并且它沒有在視頻中顯示給她。bookTicket(remainingTickets, userTickets, bookings, firstName, lastName, email, conferenceName)以上是對(duì)以下函數(shù)的調(diào)用:func bookTicket(remainingTickets uint, userTickets uint, bookings []string, firstName string, lastName string, email string, conferenceName string) {remainingTickets = remainingTickets - userTicketsbookings = append(bookings, firstName+" "+lastName)它說“這個(gè)預(yù)訂價(jià)值從未使用過(SA4006)”所以,這里是整個(gè)代碼:https://go.dev/play/p/GFMR7f64li1package mainimport (    "fmt"    "strings")func main() {    conferenceName := "Go Conference"    const conferenceTickets int = 50    var remainingTickets uint = 50    bookings := []string{}    greetUsers(conferenceName, conferenceTickets, remainingTickets)    for {        firstName, lastName, email, userTickets := getUserInput()        isValidName, isValidEmail, isValidTicketNumber := validateUserInput(firstName, lastName, email, userTickets, remainingTickets)        if isValidName && isValidEmail && isValidTicketNumber {            bookTicket(remainingTickets, userTickets, bookings, firstName, lastName, email, conferenceName)            firstNames := getFirstNames(bookings)            fmt.Printf("The first name of our bookings are: %v\n", firstNames)            if remainingTickets == 0 {                // sair do loop/programa                fmt.Println("Our conference is booked out. Come back next year.")                break            }        } else {            if !isValidName {                fmt.Println("First name or last name too short.")            }            if !isValidEmail {                fmt.Println("E-mail doesn't contain @ sign.")            }            if !isValidTicketNumber {                fmt.Println("Number of tickets entered is invalid.")            }        }    }}
查看完整描述

2 回答

?
動(dòng)漫人物

TA貢獻(xiàn)1815條經(jīng)驗(yàn) 獲得超10個(gè)贊

因此,我對(duì)代碼進(jìn)行了一些清理,現(xiàn)在它又按預(yù)期工作了。


現(xiàn)在作為包級(jí)別變量bookings在外部并且它可以工作。main


package main


import (

    "fmt"

    "strings"

)


const conferenceTickets int = 50


var conferenceName = "Go Conference"

var remainingTickets uint = 50


var bookings = []string{}

現(xiàn)在的bookTickets電話是:


bookTicket(userTickets, firstName, lastName, email)

調(diào)用函數(shù):


func bookTicket(userTickets uint, firstName string, lastName string, email string) {

    remainingTickets = remainingTickets - userTickets

    bookings = append(bookings, firstName+" "+lastName)


    fmt.Printf("Thank you %v %v for booking %v tickets. You will receive a confirmation email at %v\n", firstName, lastName, userTickets, email)

    fmt.Printf("%v tickets remaining for the %v.\n", remainingTickets, conferenceName)

}

多謝你們。


查看完整回答
反對(duì) 回復(fù) 2022-10-24
?
收到一只叮咚

TA貢獻(xiàn)1821條經(jīng)驗(yàn) 獲得超5個(gè)贊

與大多數(shù)其他主流語言不同,如果你不使用變量的值做某事,Go 就不允許使用變量。因此,在測試代碼中解決這個(gè)問題的方法是將值打印到控制臺(tái)。在最后添加這一行:

fmt.Println(bookings)


查看完整回答
反對(duì) 回復(fù) 2022-10-24
  • 2 回答
  • 0 關(guān)注
  • 162 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)