Skip to content

Instantly share code, notes, and snippets.

@fboeller
Last active August 8, 2019 19:16
Show Gist options
  • Save fboeller/05a0d39a2be8a814d06a452a792a761c to your computer and use it in GitHub Desktop.
Save fboeller/05a0d39a2be8a814d06a452a792a761c to your computer and use it in GitHub Desktop.
fun perimeter(shape: Shape): Double = when (shape) {
is Rectangle -> (shape.x + shape.y) * 2
is Circle -> 2 * PI * shape.radius
is Parallelogram -> (shape.base + shape.side) * 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment