Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Go Language Go Language Overview Custom Types Methods

Kiwi Moe
Kiwi Moe
3,365 Points

It seems to work correctly on my local computer,but showed Bummer when check work

It told me hours(0).Increment() should be 1,but showed 0. and this method return 1 on my computer

src/clock/hours.go
package clock

type Hours int

func (h Hours) Increment() Hours {
    return (h + 1) % 24
}

1 Answer

I recommend re-watching the video. :wink:

  • You don't return anything. Your function is still returning type Hours.
  • The argument should be a pointer.
  • When you access or change the value of the parameter, you need to "unbox" (more formally, dereference) the pointer passed in.
func (h *Hours) Increment() {
    *h = (*h + 1) % 24
}

Happy coding! :zap: ~Alex