Skip to content

Instantly share code, notes, and snippets.

@lucaspolo
Created October 3, 2021 20:08
Show Gist options
  • Save lucaspolo/8f71eaef4ee3b5d57c93528f071e2316 to your computer and use it in GitHub Desktop.
Save lucaspolo/8f71eaef4ee3b5d57c93528f071e2316 to your computer and use it in GitHub Desktop.
object CasamentoDePadroes extends App {
case class Pessoa(nome: String, idade: Int);
var pessoa = Pessoa("Linus", 51);
var mensagem = pessoa match {
case Pessoa("Lucas", _) => "Olá programador Lucas"
case Pessoa(nome, idade) if idade > 50 => s"Olá Sr(a) $nome"
case Pessoa(nome, _) => s"Olá $nome"
case _: Pessoa => "Olá desconhecido"
case _ => "Error"
}
println(mensagem)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment