This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Answer these questions to demonstrate what you've learned:
Can variables that are declared within an if statement be used outside the if statement?
if
Yes, because variables have a global scope.
No, the variable scope is only within the if block or nested if statements.
Yes, as long as they're used within the function.
No, a variable must be declared outside an if statement.
In a switch block, does a break keyword need to be included at the end of every case statement?
switch
break
case
No, Go doesn't require you to include the break keyword.
Yes, otherwise the following case statements will be evaluated.
No, Go doesn't support the break keyword.
What does the panic() function do in Go?
panic()
It throws an error that you need to catch. Otherwise, the program crashes without any error.
It prints a panic message to the console.
It crashes a program and prints the error message and its stack trace.
You must answer all questions before checking your work.
Continue
Was this page helpful?