Question | Click to View Answer |
What does the following code print to the console? var sauces [3]string
sauces[0] = "ketchup"
sauces[1] = "bbq"
sauces[2] = "mayo"
fmt.Println(sauces)
|
The string The string The string The |
What does the following code print to the console? numbers := [3]int{20, 22, 29}
fmt.Println(numbers)
|
This example uses Go's shorthand syntax to create an array. Go arrays have a fixed length and the |
What does the following code print to the console? primes := [5]int{1, 2, 3}
fmt.Println(primes)
|
The |
What does the following code print to the console? cheeses := [5]string{"parm", "blue", "gouda"}
fmt.Println(cheeses[2])
|
|
What does the following code print to the console? countries := [2]string{"peru", "argentina"}
countries[1] = "uruguay"
fmt.Println(countries)
|
The |
What does the following code print to the console? colors := [2]string{"red", "yellow", "blue"}
fmt.Println(colors)
|
This code returns the following error: The |
What does the following code print to the console? pastas := [4]string{"carbonara", "pesto"}
fmt.Println(len(pastas))
|
The |
What does the following code print to the console? soups := [4]string{
"pho",
"chicken noodle",
"sancocho",
}
fmt.Println(soups[2])
|
|
What does the following code print to the console? balkans := [2]string{
"croatia",
"serbia"
}
fmt.Println(balkans)
|
The code returns the following error: When the multiline array syntax is used, each element must be followed by a comma. This code should be refactored as follows: balkans := [2]string{
"croatia",
"serbia",
}
fmt.Println(balkans)
|