

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
Not enough gems
Cost: 6 gems
1: Structs in Go
incomplete
2: Nested Structs in Go
incomplete
3: Anonymous Structs in Go
incomplete
4: Embedded Structs
incomplete
5: Struct Methods in Go
incomplete
6: Memory Layout
incomplete
7: Empty Struct
incomplete
8: Empty Struct
incomplete
9: Update Users
incomplete
10: Send Message
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Structs can be nested to represent more complex entities:
type car struct {
brand string
model string
doors int
mileage int
frontWheel wheel
backWheel wheel
}
type wheel struct {
radius int
material string
}
The fields of a struct can be accessed using the dot . operator.
myCar := car{}
myCar.frontWheel.radius = 5
Textio has a bug, we've been sending texts that are missing critical bits of information! Before we send text messages in Textio, we must check to make sure the required fields have non-zero values.
Notice that the user struct is a nested struct within the messageToSend struct. Both sender and recipient are user struct types.
Complete the canSendMessage function. It should return true only if the sender and recipient fields each contain a name and a number. If any of the default zero values are present, return false instead.
Zero values:
0false""