Quiz · Structs and methods · lesson 4 of 11
Quiz — method and function
What does the program print?
package main
import "fmt"
type Rect struct{ W, H int }
func (r Rect) Area() int { return r.W * r.H }
func Area(w, h int) int { return w + h }
func main() {
r := Rect{2, 3}
fmt.Println(r.Area(), Area(2, 3))
}Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.