Skip to content

Instantly share code, notes, and snippets.

@s1monw1
Created May 29, 2023 08:05
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 s1monw1/0e2ee5157297b0363d89859151845348 to your computer and use it in GitHub Desktop.
Save s1monw1/0e2ee5157297b0363d89859151845348 to your computer and use it in GitHub Desktop.
// 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