0

Reset The Timer

Does anybody solve this task in Golang?

13th May 2021, 5:22 PM
Václav Dostál
Václav Dostál - avatar
6 Respostas
+ 1
Václav Dostál I did this way: package main import "fmt" type Timer struct { id string seconds int } func main() { var x int fmt.Scanln(&x) t := Timer{"ABC", x} reset(&t) fmt.Println(t) } // my implementation is written below func reset(t *Timer) { t.seconds = 0 }
23rd May 2021, 2:07 AM
Lucas Kliemczak
Lucas Kliemczak - avatar
+ 1
Previously I didn't know how to solve it, then I found this material in the following link with some examples and it helped me. https://tour.golang.org/methods/5
23rd May 2021, 2:09 AM
Lucas Kliemczak
Lucas Kliemczak - avatar
+ 1
package main import "fmt" type Timer struct { id string seconds int } func reset(t *Timer) { t.seconds = 0 } func main() { var x int fmt.Scanln(&x) t := Timer{"ABC", x} reset(&t) fmt.Println(t) }
20th Apr 2023, 3:22 PM
Esa Krissa
Esa Krissa - avatar
0
package main import "fmt" type Timer struct { id string seconds int } func reset(t *int) { //t := &Timer{Timer.name, 0} //*x = 0 } func main() { var x int fmt.Scanln(&x) t := Timer{"ABC", x} reset(&t) fmt.Println(t) }
13th May 2021, 5:32 PM
Václav Dostál
Václav Dostál - avatar
0
This task I mean
13th May 2021, 5:33 PM
Václav Dostál
Václav Dostál - avatar
0
Nice but I need help with the task Reset The Timer in Golang course.
13th May 2021, 5:38 PM
Václav Dostál
Václav Dostál - avatar