Skip to content
Quiz · Structs and methods · lesson 6 of 11

Quiz — a value-receiver method

What does the program print?

GO
package main

import "fmt"

type Counter struct{ n int }

func (c Counter) Inc() int { c.n++; return c.n }

func main() {
    var c Counter
    fmt.Println(c.Inc(), c.Inc())
}

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way