Created
May 29, 2023 08:05
-
-
Save s1monw1/0e2ee5157297b0363d89859151845348 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// This does not compile because the `when` is not exhaustive | |
fun greetMammal(mammal: Mammal): String { | |
return when (mammal) { | |
is Human -> "Hello ${mammal.name}; You're working as a ${mammal.job}" | |
is Cat -> "Hello ${mammal.name}" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment