Skip to content
Quiz · Interfaces · lesson 2 of 10

Quiz — satisfying an interface

What happens when this program is built and run?

GO
package main

import "fmt"

type Shape interface{ Area() float64 }
type Square struct{ Side int }

func (s Square) Area() int { return s.Side * s.Side }
func main() {
    var sh Shape = Square{Side: 2}
    fmt.Println(sh.Area())
}

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