Created
March 25, 2023 11:51
-
-
Save tacsio/644996f7b4368eb88a6b23f5743c1c61 to your computer and use it in GitHub Desktop.
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
sealed class Shape permits Circle, Rectangle { | |
double getArea() { | |
return switch(this) { | |
case Circle(double r) -> Math.PI * r * r; | |
case Rectangle(double h, double w) -> h * w; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment