Pagina de inicio
/
Tecnología
/
What does the following code do? type Vehicle struct { year int make string model string VIN string Defines a new type called "Vehicle" in Go Doesn't compile, syntax error Declares a variable of type "Vehicle" in Go

Problemas

What does the following code do?
type Vehicle struct {
year int
make string
model string
VIN string
Defines a new type called "Vehicle" in Go
Doesn't compile, syntax error
Declares a variable of type "Vehicle" in Go

What does the following code do? type Vehicle struct { year int make string model string VIN string Defines a new type called "Vehicle" in Go Doesn't compile, syntax error Declares a variable of type "Vehicle" in Go

Solución

avatar
Juliomaestro · Tutor durante 5 años
expert verifiedVerificación de expertos
4.5 (288 votos)

Responder

The code defines a new type called "Vehicle" in Go. However, there is a syntax error because the `struct` keyword should be followed by curly braces `{}` to define the fields of the struct. The correct syntax should be:<br /><br />```go<br />type Vehicle struct {<br /> year int<br /> make string<br /> model string<br /> VIN string<br />}<br />```<br /><br />So, the most accurate choice from the given options is: "Doesn't compile, syntax error."
Haz clic para calificar: