Working with pointer receivers

Report a typo

Emma needs to create a method for the Gesture struct that allows her to update the Name and Emoji fields. After creating the method, she needs to print the current gesture first, and the updated gesture afterwards.

Can you help Emma write the Update() method with a pointer receiver on the Gesture struct, so her program can properly update the values of the previously mentioned fields?

She wants to update the fields of Gesture to: Thumbs-Up and 👍

Take notice that the output of her program should look like this:

The current gesture is: OK-Hand 👌
The updated gesture is: Thumbs-Up 👍

Sample Input 1:

Sample Output 1:

The current gesture is: OK-Hand 👌
The updated gesture is: Thumbs-Up 👍
Write a program in Go
package main

import "fmt"

type Gesture struct {
Name, Emoji string
}

// Update method with a pointer receiver to update 'Gesture' struct fields
func (? ?) Update(name, emoji string) {
? = ?
? = ?
}

func main() {
// Do not change the contents of the 'g' struct!
g := Gesture{
Name: "OK-Hand",
Emoji: "👌",
}

fmt.Printf("The current gesture is: %s %s\n", g.Name, g.Emoji)

// Call the Update() method on the 'g' struct and pass "Thumbs-Up" and "👍" as arguments below:
// you may copy and paste the "👍" emoji so its easier!
g.?(?, ?)

fmt.Printf("The updated gesture is: %s %s\n", g.Name, g.Emoji)
}
___

Create a free account to access the full topic