This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//./shape.go:83:6: cannot use NewSquare(5) (type *Square) as type Shape in assignment: | |
// *Square does not implement Shape (missing Area method) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Shape interface { | |
Area() int | |
} | |
type Square struct { | |
a int | |
} | |
func NewSquare(a int) *Square { | |
return &Square{a: a} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Shape interface { | |
Area() int | |
} | |
type Square struct { | |
a int | |
} | |
func NewSquare(a int) *Square { | |
return &Square{a: a} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Square struct { | |
Shape | |
Rectangle | |
a int | |
} | |
func main() { | |
s := NewSquare(5) | |
s.Shape = NewRectangle(10, 40) | |
fmt.Printf("Square's area is %v\n", s.Area()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Rectangle struct { | |
a int | |
b int | |
} | |
func NewRectangle(a, b int) *Rectangle { | |
return &Rectangle{a: a, b: b} | |
} | |
func (s *Rectangle) Area() int { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Shape interface { | |
Area() int | |
} | |
type Square struct { | |
Shape | |
a int | |
} | |
func NewSquare(a int) *Square { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
type Shape interface { | |
Area() int | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Shape interface { | |
Area() int | |
} | |
type Square struct { | |
a int | |
} | |
func NewSquare(a int) *Square { | |
return &Square{a: a} |