example

package
v0.0.0-...-4bfa621 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2015 License: MPL-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Circle

type Circle struct {
	Center Point
	Radius float64
}

func (Circle) Shape

func (v Circle) Shape() Shape

Shape converts a Circle to an instance of the sum type Shape.

type Point

type Point struct {
	X, Y float64
}

type Rectangle

type Rectangle struct {
	LowerLeft     Point
	Width, Height float64
}

func (Rectangle) Shape

func (v Rectangle) Shape() Shape

Shape converts a Rectangle to an instance of the sum type Shape.

type Shape

type Shape interface {

	// Circle returns a Circle and a boolean. When the second return value is true,
	// the Shape is the returned Circle.
	Circle() (Circle, bool)

	// Rectangle returns a Rectangle and a boolean. When the second return value is true,
	// the Shape is the returned Rectangle.
	Rectangle() (Rectangle, bool)
}

A Shape is one of

  • Circle
  • Rectangle

In each implementation exactly one of the methods should have the second return value be true.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL