Skip to content

Instantly share code, notes, and snippets.

@achilles42
Created October 11, 2015 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save achilles42/48e25424e1e36e2b432f to your computer and use it in GitHub Desktop.
Save achilles42/48e25424e1e36e2b432f to your computer and use it in GitHub Desktop.
package main
import "fmt"
type Rectangle struct {
length, width int
}
func (r *Rectangle) Area() int {
return r.length * r.width
}
func (r *Rectangle) per() int {
return 2 * (r.length + r.width)
}
type Square struct {
rectangle := new(Rectangle) //creating the reference for rectange struct
length int
}
func (s *Square) Area() int {
return s.length * s.length
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment