

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Constants
incomplete
2: Computed Constants
incomplete
3: Comparing Go's Speed
incomplete
4: Formatting Strings in Go
incomplete
5: Runes and String Encoding
incomplete
6: Fix Bugs
incomplete
7: Fix Types
incomplete
8: Type Inference
incomplete
9: Format Practice
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Constants must be known at compile time. They are usually declared with a static value:
const myInt = 15
However, constants can be computed as long as the computation can happen at compile time.
For example, this is valid:
const firstName = "Lane"
const lastName = "Wagner"
const fullName = firstName + " " + lastName
That said, you cannot declare a constant that can only be computed at run-time like you can in JavaScript. This breaks:
// the current time can only be known when the program is running
const currentTime = time.Now()
Keeping track of time in a message-sending application is critical. Imagine getting an appointment reminder an hour after your doctor's visit.
Complete the code using a computed constant to print the number of seconds in an hour.